Combinations and permutations: Difference between revisions

Added 11l
(Added 11l)
Line 24:
{{Template:Combinations and permutations}}
<br><br>
 
=={{header|11l}}==
{{trans|C++}}
 
<lang 11l>F perm(=n, p)
BigInt r = 1
V k = n - p
L n > k
r *= n--
R r
 
F comb(n, =k)
V r = perm(n, k)
L k > 0
r I/= k--
R r
 
L(i) 1..11
print(‘P(12,’i‘) = ’perm(12, i))
L(i) (10.<60).step(10)
print(‘C(60,’i‘) = ’comb(60, i))</lang>
 
{{out}}
<pre>
P(12,1) = 12
P(12,2) = 132
P(12,3) = 1320
P(12,4) = 11880
P(12,5) = 95040
P(12,6) = 665280
P(12,7) = 3991680
P(12,8) = 19958400
P(12,9) = 79833600
P(12,10) = 239500800
P(12,11) = 479001600
C(60,10) = 75394027566
C(60,20) = 4191844505805495
C(60,30) = 118264581564861424
C(60,40) = 4191844505805495
C(60,50) = 75394027566
</pre>
 
=={{header|ALGOL 68}}==
1,481

edits