Techniques used in FIB1

IFTE (if thenelse function). The defining procedure for FIB1 contains the conditional function IFTE, which can take its argument either from the stack or in algebraic syntax.

Recursion. The defining procedure for FIB1 is written in terms of FIB1, just as Fn is defined in terms of Fn1 and Fn2 .

FIB1 program listing

Program:

Comments:

 

 

«

 

→ n

Defines local variable n.

'IFTE(n‰1,

The defining procedure, an

n,

algebraic expression. If n ≤ 1,

FIB1(n1)+FIB1(n2))'

Fn = n, else Fn = Fn1 +Fn2 .

 

»

 

 

 

`OFIB1 K

Stores the program in FIB1.

 

 

 

Checksum: # 14909d (press O%FIB1% !°#MEM# %BYTES%)

Bytes: 113.5

Example: Calculate F6. Calculate F10 using algebraic syntax.

First calculate F6.

J

6%FIB1%

Next, calculate F10 using algebraic syntax.

O%FIB1% !Ü10 N

FIB2 (Fibonacci Numbers, Loop Version

Level 1

Level 1

 

 

 

n

Fn

 

 

 

Techniques used in FIB2

IFTHENELSEEND. FIB2 uses the programstructure form of the conditional . (FIB1 uses IFTE.)

STARTNEXT (definite loop). To calculate Fn, FIB2 starts with F0 and F1 and repeats a loop to calculate successive values of Fi.

22 RPL Programming Examples

Page 82
Image 82
HP 50g Graphing, 48gII Graphing manual FIB2 Fibonacci Numbers, Loop Version, FIB1% !Ü10 N