Fibt (Comparing Program-Execution Time) - HP 48gII Advanced User's Reference Manual

Graphing calculator
Hide thumbs Also See for 48gII:
Table of Contents

Advertisement

FIB2 program listing
Program:
«
 n
«
IF n 1 ‰
THEN n
ELSE
0 1
2 n
START
NEXT
SWAP DROP
END
»
»
`O FIB2 K
Checksum: # 23902d (press O%FIB2% !°#MEM# %BYTES%)
Bytes:
89
Example: Calculate F
6
Calculate F
.
6
J
6 %FIB2%
Calculate F
.
10
10 %FIB2%

FIBT (Comparing Program-Execution Time)

FIB1 calculates intermediate values F
Consequently, FIB2 is faster. The difference in speed increases with the size of n because the time required for
FIB1 grows exponentially with n, while the time required for FIB2 grows only linearly with n.
DUP
ROT
+
and F
.
10
more than once, while FIB2 calculates each intermediate F
i
Comments:
Creates a local variable structure.
If n
1,
then F
= n;
n
otherwise ...
Puts F
and F
on the stack.
0
1
From 2 to n does the following loop:
Copies the latest F (initially F
Gets the previous F (initially F
Calculates the next F (initially F
Repeats the loop.
Drops F
.
n-1
Ends the ELSE clause.
Ends the defining procedure.
Stores the program in FIB2.
RPL Programming Examples 2-3
)
1
)
0
)
2
only once.
i

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

49g+

Table of Contents