48SX Fibonacci (with a few tricks) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: 48SX Fibonacci (with a few tricks) (/thread-10576.html) |
48SX Fibonacci (with a few tricks) - SamE - 04-25-2018 01:58 PM So, I'm new on the forums and own an 11C, a 28S, and a 48SX. I was wondering how to make a program of the Fibonacci sequence that left the numbers on the stack. The code that I use normally is: -start with 2 1s on the stack- << DO DUP ROT + CLLCD DUP 5 DISP 1 WAIT UNTIL KEY END >> This displays the numbers but doesn't leave them on the stack. RE: 48SX Fibonacci (with a few tricks) - DavidM - 04-25-2018 03:39 PM (04-25-2018 01:58 PM)SamE Wrote: This displays the numbers but doesn't leave them on the stack. Welcome to the forum, SamE! You've got a good start on this already. Using the same basic structure as what you already have above, here's one way to leave the numbers on the stack as they are being displayed: Code: « Notes: - I moved the CLLCD outside of the loop, as it doesn't really need to be executed each time. - Since you need to start with two 1s on the stack, I went ahead and included that as a convenience. - "DO ... UNTIL KEY END" leaves the pressed key code on the stack. That isn't a part of the sequence, so I thought it might be good to DROP it at the end instead of leaving it in place. RE: 48SX Fibonacci (with a few tricks) - SamE - 04-25-2018 06:56 PM That is exactly what I needed and works great! Thanks. |