Jump to content

Factorial: Difference between revisions

add TI-57
(add TI-57)
Line 9,828:
expr {round([::math::special::Gamma [expr {$n+1}]])}
}</syntaxhighlight>
 
=={{header|TI-57}}==
The program stack has only 3 levels, so the recursive approach can be skipped.
{| class="wikitable"
! Machine code
! Comment
|-
|
Lbl 0
STO 0
Lbl 1
RCL 0
×
Dsz
GTO 1
1
=
R/S
RST
|
program factorial(x) // x is the display register
r0 = x
loop
multiply r0 by what will be in the next loop
decrement r0 and exit loop if r0 = 0
end loop
complete the multiplication sequence
return x!
end program
reset program pointer
|}
 
=={{header|TorqueScript}}==
1,150

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.