Post Reply 
What comes next?
10-15-2024, 02:53 PM (This post was last modified: 10-15-2024 05:37 PM by Thomas Klemm.)
Post: #22
RE: What comes next?
(10-15-2024 01:34 PM)Gil Wrote:  My next question is if I may ask: what is the code algorithm you used in your first post to get the binomial coefficient?

Let me again add some comments:
Code:
00 { 24-Byte Prgm }         ; a_n
01 1                        ; 1 a_n
02 RCL+ 00                  ; n+1 a_n
03 STO 00                   ; n=n+1 a_n
04 X<>Y                     ; a_n n
05 ENTER                    ; a_n Σa=a_n n
06 GTO 01                   ; jump to label 01
07▸LBL 00                   ; repeat
08 RCL- IND ST Z            ; Δa_k=a_{k+1}-a_k Σa k
09 STO+ ST Y                ; Δa_k Σa=Σa+Δa_k k
10▸LBL 01                   ; a_k Σa k
11 STO IND ST Z             ; R[k]=a_k
12 DSE ST Z                 ; a_k Σa k=k-1
13 GTO 00                   ; until k==0 
14 R↓                       ; Σa
15 END

We keep the increasing number of elements \(n\) in register 00.
Let's assume we're at the situation of post #4 and we want to add 35.

The difference is calculated in register X while the sum for the next value is calculated in register Y:

\(
\begin{array}{|l|l|l|}
\hline
X & Y & Z \\
\hline
35 & 35 & 6 \\
15=35-20 & 50=35+15 & 5 \\
5=15-10 & 55=50+5 & 4 \\
1=5-4 & 56=55+1 & 3 \\
0=1-1 & 56=56+0 & 2 \\
0=0-0 & 56=56+0 & 1 \\
\hline
\end{array}
\)

Meanwhile the counter in register Z is decremented until it is 0.

I suggest to give Free42 a try.
You can copy and paste the program when the simulator is in program mode: PRGM.
Switch back and clear the registers with CLEARCLRG.
And then just follow the example.
Press ▼ to single step through the program.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
What comes next? - Thomas Klemm - 10-08-2024, 12:26 AM
RE: What comes next? - chromos - 10-08-2024, 05:16 AM
RE: What comes next? - John Keith - 10-08-2024, 12:14 PM
RE: What comes next? - Thomas Klemm - 10-08-2024, 02:31 PM
RE: What comes next? - Thomas Klemm - 10-10-2024, 05:54 AM
RE: What comes next? - Gil - 10-10-2024, 02:55 PM
RE: What comes next? - Thomas Klemm - 10-10-2024, 08:24 PM
RE: What comes next? - Gil - 10-10-2024, 09:17 PM
RE: What comes next? - Thomas Klemm - 10-11-2024, 03:12 AM
RE: What comes next? - C.Ret - 10-13-2024, 12:35 PM
RE: What comes next? - Thomas Klemm - 10-13-2024, 06:08 PM
RE: What comes next? - Geoff Quickfall - 10-13-2024, 06:33 PM
RE: What comes next? - John Keith - 10-13-2024, 08:49 PM
RE: What comes next? - Thomas Klemm - 10-14-2024, 02:14 AM
RE: What comes next? - Thomas Klemm - 10-14-2024, 06:21 AM
RE: What comes next? - Gilles - 10-14-2024, 08:35 PM
RE: What comes next? - John Keith - 10-15-2024, 05:39 PM
RE: What comes next? - FLISZT - 10-15-2024, 10:59 PM
RE: What comes next? - Thomas Klemm - 10-15-2024, 03:39 AM
RE: What comes next? - Gil - 10-15-2024, 10:09 AM
RE: What comes next? - Thomas Klemm - 10-15-2024, 11:41 AM
RE: What comes next? - Gil - 10-15-2024, 01:34 PM
RE: What comes next? - Gil - 10-15-2024, 01:53 PM
RE: What comes next? - Gilles - 10-15-2024, 04:08 PM
RE: What comes next? - John Keith - 10-15-2024, 09:09 PM
RE: What comes next? - Thomas Klemm - 10-15-2024 02:53 PM
RE: What comes next? - Thomas Klemm - 10-15-2024, 03:08 PM
RE: What comes next? - Thomas Klemm - 10-16-2024, 12:56 AM
RE: What comes next? - Thomas Klemm - 10-16-2024, 04:51 AM
RE: What comes next? - Gil - 10-16-2024, 10:14 AM
RE: What comes next? - Thomas Klemm - 10-16-2024, 11:41 AM
RE: What comes next? - Gil - 10-16-2024, 01:17 PM
RE: What comes next? - John Keith - 10-16-2024, 04:54 PM
RE: What comes next? - Gilles - 10-16-2024, 07:45 PM
RE: What comes next? - Thomas Klemm - 10-16-2024, 08:38 PM
RE: What comes next? - Thomas Klemm - 10-17-2024, 05:15 AM
RE: What comes next? - Gil - 10-17-2024, 10:16 AM
RE: What comes next? - Gilles - 10-18-2024, 07:53 PM
RE: What comes next? - Gil - 10-18-2024, 10:49 PM
RE: What comes next? - John Keith - 10-18-2024, 11:57 PM
RE: What comes next? - FLISZT - 10-19-2024, 12:03 AM
RE: What comes next? - Albert Chan - 10-19-2024, 01:29 AM
RE: What comes next? - Thomas Klemm - 10-19-2024, 12:03 AM
RE: What comes next? - Thomas Klemm - 10-19-2024, 12:17 AM
RE: What comes next? - Gil - 10-19-2024, 01:00 AM
RE: What comes next? - Thomas Klemm - 10-19-2024, 08:12 AM
RE: What comes next? - Albert Chan - 10-19-2024, 09:09 PM
RE: What comes next? - Albert Chan - 10-20-2024, 08:44 PM
RE: What comes next? - Gil - 10-19-2024, 06:08 PM
RE: What comes next? - Thomas Klemm - 10-19-2024, 11:25 PM
RE: What comes next? - Thomas Klemm - 10-20-2024, 09:39 PM



User(s) browsing this thread: 5 Guest(s)