HP -28S Manual page 248

Advanced scientific calculator
Hide thumbs Also See for HP-28S:
Table of Contents

Advertisement

FIB1 (Fibonacci Numbers, Recursive Version)
Arguments
Results
1:
n
Techniques:
• IFTE (1£-Then-Else function). The defining expression for FIBI con-
tains the conditional function IFTE, which can be used in either
RPN or algebraic syntax. (FIB2 uses the program structure IF .,.
THEN ... ELSE ... END.)
• Recursion. The defining expression for FIB1 is written in terms of
FIB!, just as Fn is defined in terms of Fn _
1
and Fn -
2'
Program
IFTE(n,fl,
n ..
FI81(n-l)+FI81(n-2»
::;:.
I
ENTER
I
c:J
FIB1
I
8TO
I
Comments
Begin the program.
Define a local variable.
Begin the defining expression.
Ifn~!'
Then Fn
=
n;
Else Fn
=
Fn -
1
+
Fll -
2'
End the defining expression.
End the program.
Put the program on the stack.
Store the program as FIB 1.
Example. Calculate F6 using RPN syntax and FlO using algebraic
syntax.
First calculate F6 using RPN.
16US~:~'
ILDD9lI ___
..:1
Next calculate FlO using algebraic syntax.
c:J
FIB 1
IT]
10
I
EVAL
I
.-::13,.....------------,1
~lIilIIIIuma
_ _
..i!
28: Programming Examples
247

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents