HP Forums
(12C Platinum) Factorial - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C Platinum) Factorial (/thread-12288.html)

(12C Platinum) Factorial - Gamo - 01-28-2019 05:42 AM

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
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.


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

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