HP Forums

Full Version: (12C Platinum) Factorial
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ALG mode solution program to calculate Factorial.

This program is just the demonstration
of the use of [LSTx] in ALG mode.

HP-12C Platinum User's Guide explain how [LSTx] work in ALG mode.

The displayed number is copied into the [LSTx] register when a new calculation
commences.
In general, [LSTx] in ALG mode is only useful in programs, where it can often be
used instead of a numbered storage register, as it persists unchanged at least
until digit entry or [LSTx] itself.

-------------------------------------------------
Procedure:

For n ≤ 69

n [R/S] display n!
------------------------------------------------
Program: ALG Mode
Quote:1 [STO] 0 [X<>Y] // Set R0 for later Multiplication
1 [-] [X<>Y] [=] [CHS] //1 subtract (original number), Result negative then change sign
[x] [LSTx] [=] [STO] x 0 // Above answer multiply by (original number)
[LSTx] [-] 2 [=] // Subtract 2 from (original number)
1 [X<>Y] [X≤Y] // Start Recursive Loop
[GTO] 022 // If reach to 1 then FINISH
[GTO] 004 // If not reach to 1 then keep continue.
[RCL] 0 // Final Answer for Factorial

Remark:
This demo program not include 0! = 1 and no negative integer allow.


Gamo
Reference URL's