03062020, 02:42 PM
I use the word "programming" a bit loosely, because this model does little more than record a sequence of keystrokes, with a placeholder (ENT) to pause and get user input. It has somewhere around 150 program steps that can be split up across 4 programs, but programs can't call each other. This is literally the full extent of the flow control and decision making:
 Pause and display a result (HLT)
 Pause the program and accept an input (ENT)
 Restart the program (RTN)
 Restart the program if x>0
 Restart the program if x<=M
No labels, no goto.
Despite this, the manual has a few clever sample programs, like this one that simulates indirect addressing to accumulate frequency sums for a fivebucket histogram:
Initialize the program by pressing Shift KAC, then I. Input the bucket number (15) and press RUN, then input the value/frequency and press RUN. Keep entering bucket number and frequency pairs, and press II to view the totals (press RUN to view the next total).
Arguably, one could simply use K in + n to accumulate the values, but the program saves one keystroke per data pair, and you don't risk destroying a total if you miss the + key.
You wouldn't think it would be possible to write a prime factor finder on a calculator with no Int or Frac functions, and no flow control besides "once more from the top", but fortunately I have more determination than sense, so here it is. The program needs all 7 storage registers and uses Fix 0 mode and the Rnd function to round division results, which is just enough to test divisibility. It can factor 9,999,999,999 in about a minute. There is definitely no mod 30 sieve here.
To use the program, enter the number to factor and press I. Then press II to start factoring. The program will stop when it finds a factor. Press RUN to find the next factor. The program will deliberately cause an error to end early once the divisor has exceeded the square root of the remaining numerator (it does this by attempting to take the square root of the numerator's square root minus the divisor  just pretend the "E" stands for End). Press AC, K out 1 to see the final factor.
The program can accurately factor any integer up to the full 10digit precision of the calculator, if you're patient enough. (e.g. it doesn't think 2 is a factor of 9,999,999,999.)
 Pause and display a result (HLT)
 Pause the program and accept an input (ENT)
 Restart the program (RTN)
 Restart the program if x>0
 Restart the program if x<=M
No labels, no goto.
Despite this, the manual has a few clever sample programs, like this one that simulates indirect addressing to accumulate frequency sums for a fivebucket histogram:
Code:
Prog I
ENT
M in
ENT
K in 6
K in + 5
5
x<=M
K out 6
K in  5
K in + 4
4
x<=M
K out 6
K in  4
K in + 3
3
x<=M
K out 6
K in  3
K in + 2
2
x<=M
K out 6
K in  2
K in + 1
1
RTN
Prog II
K out 1
HLT
K out 2
HLT
K out 3
HLT
K out 4
HLT
K out 5
Initialize the program by pressing Shift KAC, then I. Input the bucket number (15) and press RUN, then input the value/frequency and press RUN. Keep entering bucket number and frequency pairs, and press II to view the totals (press RUN to view the next total).
Arguably, one could simply use K in + n to accumulate the values, but the program saves one keystroke per data pair, and you don't risk destroying a total if you miss the + key.
You wouldn't think it would be possible to write a prime factor finder on a calculator with no Int or Frac functions, and no flow control besides "once more from the top", but fortunately I have more determination than sense, so here it is. The program needs all 7 storage registers and uses Fix 0 mode and the Rnd function to round division results, which is just enough to test divisibility. It can factor 9,999,999,999 in about a minute. There is definitely no mod 30 sieve here.
Code:
Prog I
K in 1
sqrt
M in
1
K in 2 Divisor increment
2
K in 3 Divisor
Mode Fix 0 (Mode 7 0) Used for rounding
Prog II
MR M must be >= K 3 when keying in the program!

K out 3
=
sqrt Cause an error if the divisor is greater than the square root of the numerator
K out 1 Divide current numerator by divisor
/
K out 3
K in 5 Save the current divisor for later
=
Rnd Round the result
K in 4 Save the result for later
K out 2 Fetch the current divisor increment
K in 6 Save the current divisor increment for later
K in + 3 Increment the divisor
2 Set the divisor increment to 2
K in 2
K out 4 Multiply the rounded division result...
*
K out 5 ...by the previously used divisor

K out 1 Subtract the original numerator
=
x>0 Restart if difference > 0
+/
x>0 Restart if difference < 0
K out 5 Show the factor
HLT
K in / 1 Divide the current numerator by the divisor
K out 1 Get the remaining numerator
sqrt
M in Update the square root
K out 6 Restore the previous divisor increment...
K in 2
K in  3 ...and roll back the divisor to test the same divisor again
RTN
To use the program, enter the number to factor and press I. Then press II to start factoring. The program will stop when it finds a factor. Press RUN to find the next factor. The program will deliberately cause an error to end early once the divisor has exceeded the square root of the remaining numerator (it does this by attempting to take the square root of the numerator's square root minus the divisor  just pretend the "E" stands for End). Press AC, K out 1 to see the final factor.
The program can accurately factor any integer up to the full 10digit precision of the calculator, if you're patient enough. (e.g. it doesn't think 2 is a factor of 9,999,999,999.)