Post Reply 
Example Program to calculate Factorial
02-22-2018, 01:11 AM
Post: #40
RE: Example Program to calculate Factorial
.
Hi all,

A little late but I couldn't resist. This is my attempt at a factorial program which was one of the first programs I wrote some 40+ years ago after I just bought a new, shiny HP-25:

01 STO 0      01     23 00
02 STO/ 0     02  23 71 00
03 STOx 0     03  23 61 00
04 1          04        01
05 -          05        41
06 X#0?       06     15 61
07 GTO 03     07     13 03
08 RCL 0      08     24 00


to run it, and a few selected cases:

f PRGM, FIX 0

1 R/S -> 1
5 R/S -> 120
13 R/S -> 6227020800
69 R/S -> 1.7112245 98 (1.711224522e98 internally)

0 R/S -> Error
70 R/S -> OF (Overflow) RCL 0 -> 9.9999999 99


There's no need for a 09 GTO 00 step because the HP-25 fills up the entire 49-step program memory with GTO 00 instructions which are there whether you key them in or not.

As can be seen in the examples it will work for N=1 to 69, but not for 0. I found it very easy to remember and so would use it to show off on the fly my new wonderful HP-25 to people who would ask me what it could do when programmed (no HP-25C back then). They were always extremely amazed that an useful program would be so easily entered and run on the go.

V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Example Program to calculate Factorial - Valentin Albillo - 02-22-2018 01:11 AM



User(s) browsing this thread: 6 Guest(s)