Post Reply 
(12C Platinum) Factorial
01-28-2019, 05:42 AM (This post was last modified: 02-27-2019 01:44 AM by Gamo.)
Post: #1
(12C Platinum) Factorial
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
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: