Lah numbers: Difference between revisions

Added Arturo implementation
(Added Algol 68)
(Added Arturo implementation)
Line 235:
12 0 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
</pre>
 
=={{header|Arturo}}==
 
<lang rebol>factorial: function [n]-> product 1..n
 
lah: function [n,k][
if k=1 -> return factorial n
if k=n -> return 1
if k>n -> return 0
if or? k<1 n<1 -> return 0
return (((factorial n)*factorial n-1) / ((factorial k) * factorial k-1)) / factorial n-k
]
 
print @[pad "n/k" 5] ++ map to [:string] 0..12 's -> pad s 10
print repeat "-" 155
loop 0..12 'x [
print @[pad to :string x 5] ++ map to [:string] map 0..12 'y -> lah x y 's -> pad s 10
]</lang>
 
{{out}}
 
<pre> n/k 0 1 2 3 4 5 6 7 8 9 10 11 12
-----------------------------------------------------------------------------------------------------------------------------------------------------------
0 1 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0 0 0 0 0 0
2 0 2 1 0 0 0 0 0 0 0 0 0 0
3 0 6 6 1 0 0 0 0 0 0 0 0 0
4 0 24 36 12 1 0 0 0 0 0 0 0 0
5 0 120 240 120 20 1 0 0 0 0 0 0 0
6 0 720 1800 1200 300 30 1 0 0 0 0 0 0
7 0 5040 15120 12600 4200 630 42 1 0 0 0 0 0
8 0 40320 141120 141120 58800 11760 1176 56 1 0 0 0 0
9 0 362880 1451520 1693440 846720 211680 28224 2016 72 1 0 0 0
10 0 3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1 0 0
11 0 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1 0
12 0 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1</pre>
 
=={{header|AWK}}==
1,532

edits