Post Reply 
Example Program to calculate Factorial
02-01-2018, 08:06 PM
Post: #12
RE: Example Program to calculate Factorial
... and HP-12C version in engineer style:

The core is 3 steps:
Code:
01: LN
02: \GS-
03: GTO 01

Preparation for use required to clear statistics registers, store your number (N) in R1, then goto the start of program memory, run the program and you'll get the -LN(N!) in R2.
You can get N! if you type
Code:
RCL 2
CHS
e^x

If you like waste some memory you can program it fully (9 steps):
Code:
01: STO 1
02: LN
03: \GS-
04: x=0
05: GTO 07
06: GTO 02
07: RCL 2
08: CHS
09: e^x

Use:
1.) f CLEAR \GS
2.) f CLEAR PRGM
3.) Type N
4.) R/S

Benchmark:
69! = 1.711224655E99, running time: 62 secs on "classic" 12C Made in Brazil (S/N: 3107B...)

Some hints are welcome to optimize the code (twisted GTO 07/02 really terrible)

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


Messages In This Thread
RE: Example Program to calculate Factorial - Csaba Tizedes - 02-01-2018 08:06 PM



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