HP 9100B Operating & Programming Manual page 97

Hide thumbs Also See for 9100B:
Table of Contents

Advertisement

PROGRAMMING
THE 91008
PROGRAM KEYS- CONDITIONAL BRANCHING
The
above program also illustrates the following:
a)
CLEAR is not always a necessary instruct1on;
b)
use of PAUSE to view partial results of the pro-
gram;
c)
manipulat1on of the contents of the X, Y and Z
registers so that storage registers are not re-
qulred;
d)
use of
END,
at step
09,
to automatically reset
the program counter to (
+
)00; 1f the program
is to be recorded on a magnet1c card the END
instruct1on must be changed to STOP
e)
the sign of the page is not required in the
branching instructions (steps 07, 08 and 10,
11) as the branches do not change pages.
The following program calculates N! A new value for
N
can be
entered at the end of the program, s1nce END automatically sets
the program counterback to
(+
)00
.
This program can calcu
-
late N! for values of N up to, and includ1ng,
69.
N!
=
N (N
-
1)
(N
-
2)
-
---
-(N- N
+
2)
(1)
6!
=
(6) (5) (4) (3) (2) (1)
:
720
0!
=
1 (by definition)
(ln the program)N
=
number entered;
NO
Multiply
(P
x n)
=
P
Subtract
(n
-
1)
=
n
n
=
the current multiplier term
N,
(N
-
1)
,
(N
-
2), etc.
P
=
the partial N!
EnterN.-------
-
- - - -
-
-,
I
I
Store N
~
C
+
)f
I
I
I
I
I
I
N becomes n
1
becomes
P
YES
p
=
N!
Recall N
End,
Display
L _
_
_ _ _
J
87

Advertisement

Table of Contents
loading

Table of Contents