Lah numbers: Difference between revisions

Added XPL0 example.
(→‎{{header|Python}}: Python 2 -> Python 3; use functions from built-in math module)
(Added XPL0 example.)
Line 2,523:
11 0 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1
12 0 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
</pre>
 
=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">func real Factorial(N);
real N, Res;
[Res:= 1.;
if N = 0. then return Res;
while N > 0. do [Res:= Res*N; N:= N-1.];
return Res;
];
 
func real Lah(N, K);
real N, K;
[if K = 1. then return Factorial(N);
if K = N then return 1.;
if K > N then return 0.;
if K < 1. or N < 1. then return 0.;
return (Factorial(N) * Factorial(N-1.)) / (Factorial(K) * Factorial(K-1.)) /
Factorial(N-K);
];
 
int Row, I;
[Text(0, "Unsigned Lah numbers: L(N,K):"); CrLf(0);
Text(0, "N/K");
Format(11, 0);
for I:= 0 to 12 do RlOut(0, float(I));
CrLf(0);
for Row:= 0 to 12 do
[Format(3, 0); RlOut(0, float(Row));
for I:= 0 to Row do
[Format(11, 0); RlOut(0, Lah(float(Row), float(I)))];
CrLf(0);
]
]</syntaxhighlight>
{{out}}
<pre style="font-size:66%>
Unsigned Lah numbers: L(N,K):
N/K 0 1 2 3 4 5 6 7 8 9 10 11 12
0 1
1 0 1
2 0 2 1
3 0 6 6 1
4 0 24 36 12 1
5 0 120 240 120 20 1
6 0 720 1800 1200 300 30 1
7 0 5040 15120 12600 4200 630 42 1
8 0 40320 141120 141120 58800 11760 1176 56 1
9 0 362880 1451520 1693440 846720 211680 28224 2016 72 1
10 0 3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1
11 0 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1
12 0 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
</pre>
 
297

edits