TI-60: Triangle Numbers - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not remotely HP Calculators (/forum-9.html) +--- Thread: TI-60: Triangle Numbers (/thread-11956.html) TI-60: Triangle Numbers - Eddie W. Shore - 12-16-2018 03:35 AM Here I exploit TI-60's RST function's ability to continue program execution and using the square root function as a "tester" to calculate triangle numbers. Instructions: 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 Code:  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:  √  // take the square root of R1, if R1<0, the error occurs, ending the "loop" PC11  OP22:  RST  // reset back to step 00 Link to blog post: https://edspi31415.blogspot.com/2018/12/ti-60-triangle-numbers.html RE: TI-60: Triangle Numbers - Dieter - 12-16-2018 05:33 PM (12-16-2018 03:35 AM)Eddie W. Shore Wrote:  Here I exploit TI-60's RST function's ability to continue program execution and using the square root function as a "tester" to calculate triangle numbers. This is essentially a "proof of concept" on how to do loops on a calculator with an extremely limited function set without tests and goto – rskey.org calls the TI-60 "almost programmable". ;-) In real life, if you want the sum of all integers from 1 to n you'd of course use the direct formula ½n(n+1) or ½(n²+n). Less steps, direct result. Dieter RE: TI-60: Triangle Numbers - grsbanks - 12-16-2018 07:08 PM (12-16-2018 03:35 AM)Eddie W. Shore Wrote:  Here I exploit TI-60's RST function's ability to continue program execution Such a pain in the rear end that the TI-56 (and presumably the TI-55III) halt execution before resetting the program counter making it impossible to program loops of any kind! Even the prehistoric TI-53 does it "right" RE: TI-60: Triangle Numbers - Thomas Klemm - 12-16-2018 09:56 PM (12-16-2018 05:33 PM)Dieter Wrote:  In real life, if you want the sum of all integers from 1 to n you'd of course use the direct formula ½n(n+1) or ½(n²+n). Less steps, direct result. The TI-60 provides an nCr key with a bit weird usage: Quote:The values of n and r are entered as n.rrr. Thus we could use: Code: + 1.002 = nCr Cheers Thomas RE: TI-60: Triangle Numbers - ijabbott - 12-17-2018 02:55 PM (12-16-2018 09:56 PM)Thomas Klemm Wrote:   (12-16-2018 05:33 PM)Dieter Wrote:  In real life, if you want the sum of all integers from 1 to n you'd of course use the direct formula ½n(n+1) or ½(n²+n). Less steps, direct result. The TI-60 provides an nCr key with a bit weird usage: Quote:The values of n and r are entered as n.rrr. Thus we could use: Code: + 1.002 = nCr Cheers Thomas Using the formula saves a couple of program steps (assuming there are no pending operations before running the program): Code: + x² = ÷ 2 = RE: TI-60: Triangle Numbers - Thomas Klemm - 12-19-2018 04:23 AM (12-16-2018 05:33 PM)Dieter Wrote:  This is essentially a "proof of concept" on how to do loops on a calculator with an extremely limited function set without tests and goto We could exploit the integration key and do some calculations in a loop as a side effect. This allows to implement a solver using fixed point iteration or Newton's method. However you could specify only up to 99 loops. To solve Kepler's equation: $$M = E - e \sin E$$ We would rewrite it as a fixed point equation: $$E = M + e \sin E$$ Using the following mapping to the data memories: E: 3 M: 4 e: 5 We could then use this program: Code: RCL 4 + RCL 5 × RCL 3 sin = STO 3 We don't really care about the lower and upper limits of the interval so we could just use: 0 STO 1 1 STO 2 The integration would be started with: ∫dx nn R/S The result could then be found in register 3. Using realistic values (e.g. e = 0.0167 for the Earth) this needs only a few iterations. Don't forget to put the calculator into the radian mode. Cheers Thomas