Post Reply 
Example Program to calculate Factorial
02-02-2018, 08:28 AM
Post: #19
RE: Example Program to calculate Factorial
(02-02-2018 02:44 AM)Gene Wrote:  For historical purposes and ideas...

Here is factorial from V2N10P11 of PPC Journal:

01 STO 0
02 GTO 05
03 -
04 ST0 x 0
05 1
06 X<Y
07 GTO 03
08 X=Y
09 RCL 00
10 GTO 00 (or R/S)

That's a nice one.

(02-02-2018 02:44 AM)Gene Wrote:  Here is factorial from V3N5P4

01 STO 0
02 1
03 -
04 STO x 0
05 1
06 X NE Y
07 GTO 03
08 RCL 0
09 GTO 00

This one doesn't get 0! right and it even fails for 1!. Both inputs cause an infinite loop. But that's not worse than the solution in the Applications Progams book which fails in the same way – just another example of poor programming by HP themselves. I really wonder if they were not able to do better or if they simply didn't care. #-\

(02-02-2018 02:44 AM)Gene Wrote:  Also from V3N5P4

01 ENTER
02 ENTER
03 1
04 X=Y
05 GTO 10
06 -
07 X
08 LASTX
09 GTO 03
10 RDN
11 RDN
12 GTO 00

And that one also cannot handle 0!.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Example Program to calculate Factorial - Dieter - 02-02-2018 08:28 AM



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