EasyManuals Logo

HP HP-28S User Manual

HP HP-28S
341 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #249 background imageLoading...
Page #249 background image
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

Table of Contents

Other manuals for HP HP-28S

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP HP-28S and is the answer not in the manual?

HP HP-28S Specifications

General IconGeneral
BrandHP
ModelHP-28S
CategoryCalculator
LanguageEnglish

Related product manuals