Fibonacci Sequence  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: Fibonacci Sequence (/thread158080.html) 
Fibonacci Sequence  Mike T.  10202009 OK, Following an interesting discussion earlier this evening I thought it might be fun to see just how few keystrokes you would need to calculate successive terms of the Fibonacci Sequence, preferably without using any storage registers... I doubt it I have the best solution but thought the answer I came up with demonstrated really nicely why I like my old RPN calculator so much and that it would be interesting so see what other people came up with. Start with a one in 'x'  all other registers zero.
Re: Fibonacci Sequence  Ken Shaw  10202009 I'm assuming this is a keystroke procedure only (not a program).
In that case, I think it's just Enter Then repeat, ad infinitum. Edit: I failed to observe initially that there is no "roll up" key on most machines, including the 12C. I was surprised to realize that this also won't work on a 42S, where the keyboard uparrow is actually BST. However, it does work on my daily calc, the 17BII, because the uparrow key performs a RollUp. Unfortunately it is only a keystroke solution, not a program. Obviously this is not intended for RPL machines, as it depends on a revolving 4level stack.
Edited: 21 Oct 2009, 10:23 a.m.
Re: Fibonacci Sequence  Paul Dale  10202009 On an RPL machine (three command, ? keystroked):
SWAP OVER + On a 42 (five keystrokes, two commands):
x<>y RCL+ ST Y Still thinking about other models.... In the 20b scientific firmware there is a generalised Fibonacci function :)
 Pauli
Re: Fibonacci Sequence  Byron Foster  10202009 Quote: One command:
RCL+ ST L
Edited: 20 Oct 2009, 5:51 p.m. after one or more responses were posted
Re: Fibonacci Sequence  Paul Dale  10202009 Nice! I'd come up with an alternating sequence of:
STO+ ST Y But that isn't nearly as nice.
 Pauli
Re: Fibonacci Sequence  Byron Foster  10202009 I recently worked on this so I could try and show off the new 7 line program display mode of the 42s/Free42 in iTunes. I came up with:
01 LBL "Fibonac"
It's not perfect because it creates the sequence 1,2,3,... instead of 1,1,2,...
Fibonacci Sequence: where is Valentin Albillo?  Vieira, Luiz C. (Brazil)  10202009 Hi, all; Amongst many others, Valentim would be one of the guys to add some valuable comments to this thread... Cheers.
Luiz (Brazil) Edited: 20 Oct 2009, 6:34 p.m.
Re: Fibonacci Sequence  Paul Dale  10202009 Try:
01 LBL "Fibonac"
 Pauli
Re: Fibonacci Sequence  Byron Foster  10202009 Yea, that's better, but I was trying to get it to fit in 7 lines.
Re: Fibonacci Sequence  Paul Dale  10202009 Replace the "0 STO ST L" with CLSTK and you get to 7 steps :)
 Pauli
Re: Fibonacci Sequence  Israel Otero  10202009 Hi 01 0 The advantages are that all terms are shown and is very efficient.
Edited: 20 Oct 2009, 7:26 p.m.
Re: Fibonacci Sequence  Don Shepherd  10202009 OK, a program on our old friend, the 12c, using no registers and 7 steps:
1 Re: Fibonacci Sequence  Allen  10202009 Don Nice work.. I love how you program the Finance Calcs!!!
Re: Fibonacci Sequence  Palmer O. Hanson, Jr.  10202009 On a TI A.O.S. machine like the TI59 start with 1 in the t register and 1 in the display. Then press x<>t + and see each successive term in the display after each + .
Re: Fibonacci Sequence  Byron Foster  10202009 How about:
0
Initialization isn't pretty, but it's as non destructive as you can get, and it begins the sequence correctly.
Re: Fibonacci Sequence  Gerson W. Barbosa  10212009 Hi Don, Too late for the show, anyway an alternative 12c program that produces 0,1,1,2,3,... if we don't mind clearing some registers:
01 CLEAR SIGMA Regards,
Gerson.
Re: Fibonacci Sequence  Kiyoshi Akima  10212009 LASTxThat's four keystrokes on most RPN machines. On a lineaddressed machine like the HP25, the program becomes 01 LASTx Re: Fibonacci Sequence  Mike T.  10212009 Actually this exactly key sequence that I first came up with on my HP33C. Each sucessive iteration takes just four steps/key strokes which I thought was quite efficent, but a little cumbersome to key in...
Mike T.
Re: Fibonacci Sequence  Mike T.  10212009 Very close in approach to my 'preferred' solution and it doesn't even rely on 'Last x', but since I was using an HP33C I couldn't use Roll Up...
Mike T.
Re: Fibonacci Sequence  Mike T.  10212009 After thinking about it for a little bit on my HP33C I came up with Enter, Enter, Rdn, Rdn, + Admittedly not the absolutly the shortest number of keystrokes but it has a certain appeal...
Re: Fibonacci Sequence  Michael Meyer  10212009 I like it. Has a nice rhythm to it.
Giving credit where credit is due  Palmer O. Hanson, Jr.  10232009 In an earlier submission I gave a very short keyboard sequence for finding the series on an A.O.S. machine. The idea wasn't mine. I had seen it somewhere but couldn't locate it. Now I have found the original reference which is from V5N4/5P16 of TI PPC Notes: Quote: Re: Fibonacci Sequence  Crawl  10242009 Another 3 command RPL:
DUP ROT +
Re: Fibonacci Sequence  Kiyoshi Akima  10272009 If we can alter the initial stack conditions, it can be done in one step.
Set up the stack: 5You'll need an additional ENTER if the FIX 0 doesn't enable stack lift.
After that, press * (multiply) to see 1. Press * again to see 1. Keep going to see 2, 3, 5, 8, 13, etc.
Re: Fibonacci Sequence  Mike T.  11042009 Not sure that qualifies as the shortest but it is interesting and does show just how useful the stack can be...
Mike T.
Re: Fibonacci Sequence  Michael Meyer  11042009 Impressive. Most impressive. You may be an HP Jedi yet.
Re: Fibonacci Sequence  Ken Shaw  11052009 Very clever!
Re: Fibonacci Sequence  Gerson W. Barbosa  11072009
Quote: The stack is really useful: quite by accident (as almost everything I discover) I found it can be used to solve the equation
x Start by filling the stack with k then iterate 'ln *' until the answer on the display converges (somewhat slowly if k is close to e) to the second real solution. On my HP45:
pi As a comparison the HP33s solver gives 108.442345473 (initial guess = 100). Can a nonprogrammable algebraic calculator do this? :) Gerson.
The answer is Yes!  Palmer O. Hanson, Jr.  11082009 Gerson:
You asked: Quote: The answer is yes. Try this on a TI30:
pi then do ln x RCL = After 16 iterations you will see 108.44235 in the display with 108.44234529 in the display register. I suspect that this will work with any algebraic which has a memory. It works on my Sharp EL501W where it yields 108.4423436 after twelve iterations. Palmer
Edited: 8 Nov 2009, 1:51 p.m.
Re: The answer is Yes!  Gerson W. Barbosa  11082009
Quote:
Thanks! Next time I'll try to solve the problem on an algebraic calculator before asking :)
Gerson.
