The following program calculates T_n, the nth triangle number. Triangle numbers are determined by the sum:
T_n = ∑k, from k = 0 to n
The TI-60 does not have either comparison commands or a goto command. Luckily for the TI-60 (not the case for the TI-55 III), the RST sends the program pointer back to the first step (Step 00) and continues to execute.
We simulate a loop by counting down, when the counter reaches -1, the square root function will cause an error, forcing execution to stop. You’ll see this trick towards the end of the program.
1. In RUN mode (outside of LRN), store the following values:
R0 = 0
R1 = n
2. Execute the program by pressing [RST], [R/S]. The program is done when you see “Error”.
3. Clear the error by pressing [CE/C].
4. Recall R0. This is your triangle number. (R1 will have -1).
TI-60 Program: Triangle Numbers
PC00 OP71: RCL
PC01 OP01: 1
PC02 OP61: STO
PC03 OP85: +
PC04 OP00: 0 // sum R1 in R0
PC05 OP75: –
PC06 OP01: 1
PC07 OP95: =
PC08 OP61: STO
PC09 OP01: 1 // store R1 -1 in R1
PC10 OP86: √ // square root of R1, if less than 0, program stops
PC11 OP22: RST // reset back to step 00
T_5 = 15 (0 [STO] 0, 5 [ST0] 1, [RST] [R/S], [CE/C] [RCL] 0)
T_35 = 630 (in about 45 seconds)
All original content copyright, © 2011-2018. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. Please contact the author if you have questions.