Factorial: Difference between revisions

Content added Content deleted
(add TI-57)
m (Solve bug for 0!)
Line 9,830: Line 9,830:


=={{header|TI-57}}==
=={{header|TI-57}}==
The program stack has only 3 levels, so the recursive approach can be skipped.
The program stack has only three levels, which means that the recursive approach can be dispensed with.
{| class="wikitable"
{| class="wikitable"
! Machine code
! Machine code
Line 9,837: Line 9,837:
|
|
Lbl 0
Lbl 0
C.t
x=t
1
STO 0
STO 0
Lbl 1
Lbl 1
Line 9,849: Line 9,852:
|
|
program factorial(x) // x is the display register
program factorial(x) // x is the display register
if x=0 then
x=1
r0 = x
r0 = x
loop
loop