(35S) Fibonacci Fun for the HP35s and the number phi
|
01-24-2015, 09:53 AM
(This post was last modified: 01-24-2015 09:54 AM by MarkHaysHarris777.)
Post: #9
|
|||
|
|||
RE: Fibonacci Fun for the HP35s and the number phi
(01-24-2015 01:51 AM)Thomas Klemm Wrote: This is what I came up with: It does work to produce the Fibonacci sequence, but it does not meet my programming challenge because the numbers do not lift up the stack and out the TOP! In other words at each iteration you will only have Fib numbers in X and y; z and t will contain zero. Without the REGX and REGY (hidden) instructions it takes at least five steps to generate the sequence in such a way that the numbers lift up the stack (bump up the stack and out the top) so that at any iteration past 4 the x,y,z,t stack regs will contain the last four Fib numbers in descending order as you move up the stack. So, at iteration 5 the stack will look like this: t 1 z 2 y 3 x 5 Your algorithm will leave the stack looking like this after 5 iterations: t 0 z 0 y 3 x 5 So just the equation REGX+REGY does the trick. Didier is correct to point out that the hidden REGx instructions are documented 'loosely' in Appendix B-7. And even so, the instructions are not very intuitive in their use, and secondarily they are painfully slow. Without the REGx instructions the minimum steps to bump the Fib numbers up the stack are five(5) LASTx X<>Y + LASTx X<>Y If not the intermediate results simply collapse back into the X and Y and the Z and T never get the replicated values. Cheers PS ... smile and wave boys, just smile and wave. Kind regards, marcus |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)