Jump to content

Evaluate binomial coefficients: Difference between revisions

add TI-57
(add RPL)
(add TI-57)
Line 2,810:
<pre>5_C_3 = 10
60_C_30 = 118264581564861424</pre>
 
=={{header|TI-57}}==
{| class="wikitable"
! Machine code
! Comment
|-
|
'''Lbl 9'''
STO 2
x⮂t
STO 1
SBR 0
STO 3
RCL 1
-
RCL 2
=
SBR 0
INV Prd 3
RCL 2
SBR 0
Inv Prd 3
RCL 3
R/S
RST
'''Lbl 0'''
C.t
x=t
1
STO 0
'''Lbl 1'''
RCL 0
×
Dsz
GTO 1
1
=
INV SBR
|
'''program binomial(x,t)''' // x is the display register
r2 = x
swap x and t
r1 = x
x = factorial(x)
r3 = x
x = r1 - r2
x = factorial(x)
r3 /= x
x = r2
x = factorial(x)
r3 /= x
x = r3
end program
reset pointer
'''program factorial(x)'''
t=0
if x=0 then
x=1
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 sub
|}
<code> 5 </code> <code>x⮂t</code> <code> 3 </code> <code>GTO</code> <code> 9 </code> <code>R/S</code>
{{out}}
<pre>
10.
</pre>
 
=={{header|TI-83 BASIC}}==
1,150

edits

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