# Rpl Programming Examples; Fibonacci Numbers; Fib1 (fibonacci Numbers, Recursive Version) - HP 48gII Advanced User's Reference Manual

Graphing calculator.

## 2.RPL Programming Examples

The programs in this chapter demonstrate basic programming concepts. These programs are intended to improve
At the end of each program, the program's checksum and size in bytes are listed to help make sure you typed the
program in correctly. (The checksum is a binary integer that uniquely identifies the program based on its
contents). To make sure you've keyed the program in correctly, store it in its name, put the name in level 1, then
execute the BYTES command (!°#MEM# %BYTES%). This returns the program's checksum to level 2, and
its size in bytes to level 1. (If you execute BYTES with the program object in level 1, you'll get a different byte
count.)
The examples in this chapter assume the hp49g+/hp48gII is in its initial, default condition – they assume you
haven't changed any of the hp49g+/hp48gII operating modes. (To reset the calculator to this condition, see
"Memory Reset" in chapter 5 of the hp49g+/hp48gII User's Guide.)
Each program listing in this chapter gives the following information:
A brief description of the program.
!
A syntax diagram (where needed) showing the program's required inputs and resulting outputs.
!
Discussion of special programming techniques in the program.
!
Any other programs needed.
!
The program listing.
!
The program's checksum and byte size.
!

### Fibonacci Numbers

This section includes three programs that calculate Fibonacci numbers:
FIB1 is a user-defined function that is defined recursively (that is, its defining procedure contains its own
!
name). FIB1 is short.
FIB2 is a user-defined function with a definite loop. It's longer and more complicated than FIB1, but faster.
!
FIBT calls both FIB1 and FIB2 and calculates the execution time of each subprogram.
!
FIB1 and FIB2 demonstrate an approach to calculating the nth Fibonacci number F

### FIB1 (Fibonacci Numbers, Recursive Version)

= 0, F
= 1, F
F
0
1
Level 1
"
"
n
, where:
n
= F
+ F
n
n-
1
n-
2
Level 1
F
n
RPL Programming Examples 2-1
2