Example. Calculate
the
ratio
of
surface to volume for a box 9 inches
high, 18 inches wide,
and
21
inches long;
make
the
calculation first
in
RPN
and
then
in
algebraic syntax.
For
the
RPN version, first
enter
the
height
and
width.
~
3:
9 [ ENTER I
2:
9
. . 1: 18
18 I ENTER I 1IilD1IlIHI
___
_
Then key in
the
length
and
execute
BOXR.
21
BOXR
The ratio is .428571428571.
Now
try
the
algebraic version.
o
BOXR
[09.18.21
[EVALI
Again,
the
ratio is .428571428571.
Fibonacci Numbers
3:
2:
1:
.428571428571
1IilD1IlIHI
___
_
3:
2:
.428571428571
1:
.428571428571
1IilD1IlIHI
___
_
Given
an
integer
n,
calculate
the
nth Fibonacci
number
F
n
,
where
This section includes two programs, each
demonstrating
an
approach
to this
problem
.
• FIBI is a user function
that
is
defined
recursively-its defining ex-
pression contains its
own
name. FIB! is short, easy to
understand,
and
can
be
used
with
symbolic arguments.
•
FIB2
is a user function defined
with
a program.
It
executes faster
than
FIBl,
but
cannot
be
used
with
symbolic arguments.
246
28:
Programming
Examples