Download  Print this page

Fib2 (fibonacci Numbers, Loop Version) - HP -28S Manual

Advanced scientific calculator.
Hide thumbs

Advertisement

FIB2 (Fibonacci Numbers, Loop Version)
Arguments
Results
1:
n
Techniques:
• IF ... THEN ... ELSE ... END. FIB2 uses the program-structure
form of the conditional. (FIB1 uses IFTE.)
• START ... NEXT (definite loop). To calculate F
n ,
FIB2 starts with Fa
and F1 and repeats a loop to calculate successive F/s.
Program
.
:~:
.
::::
IF
n
,:;
THEt·j
n
EU::;E
I)
1
2
n
::H A F.: T
DUP
F.:OT
+
t~E:'<T
::;~'lAP
DF.:OP
HlD
I
ENTER
J
~
FIB2J 8TO J
Comments
Begin the program .
Create a local variable.
Begin the defining program .
Ifn~l,
Then FIl
=
n;
Begin ELSE clause.
Put Fa and F1 on the stack.
From 2 to
n,
Do the following loop:
Make a copy of the latest F (ini-
tially Fj).
Move the previous F (initially Fa)
to level 1.
Calculate the next F (initially F2)'
Repeat the loop.
Drop FIJ -
l'
End ELSE clause.
End the defining program.
End the program.
Put the program on the stack.
Store the program as FIB2.
248
28: Programming Examples

Advertisement

Table of Contents

   Also See for HP HP-28S

   Related Manuals for HP HP-28S

Comments to this Manuals

Symbols: 0
Latest comments: