Post Reply 
Example Program to calculate Factorial
02-09-2018, 01:04 AM (This post was last modified: 02-09-2018 01:05 AM by Gerson W. Barbosa.)
Post: #38
RE: Example Program to calculate Factorial
(02-08-2018 08:04 PM)Gene Wrote:  Factorial for the SR-56. Takes 14 steps out of 100. Thats' an interesting efficiency aspect vs. the HP 25, etc.

When I started using calculators, factorial was not an issue as they all had it built-in. The HP-15C which replaced my TI-59 even had Gamma!

The HP-25C is tricky because of the number-entry bug (or feature) and the lack of x<=y test. The only 10-step program I came up with is not practical as it won’t work for arguments that are results of an operation.
Code:

01 EEX
02 STO 0
03 1 
04 STO* 0
05 1
06 +
07 x<y
08 GTO 04
09 RCL 0
10 GTO 00

0 R/S -> 1.00
1 R/S -> 1.00
5 R/S -> 120.00

but

5 ENTER R/S -> 1.00

On a 25C, I would use this one instead:

Code:

01 x=0
02 e^x
03 STO 0
04 1
05 -
06 x=0
07 GTO 10
08 STO* 0
09 GTO 04
10 Rv
11 RCL 0
12 GTO 00

Why is 6 afraid of 7?

6 R/S 7 R/S * 10 R/S - -> 0

No, not because of that :-)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Example Program to calculate Factorial - Gerson W. Barbosa - 02-09-2018 01:04 AM



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