Jump to content

Lah numbers: Difference between revisions

Add SETL
(Add ABC)
(Add SETL)
Line 2,088:
 
The maximum value of L(n, k) where n = 100:
44519005448993144810881324947684737529186447692709328597242209638906324913313742508392928375354932241404408343800007105650554669129521241784320000000000000000000000</pre>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">program lah_numbers;
loop for n in [0..12] do
loop for k in [0..n] do
nprint(lpad(str lah(n,k), 11));
end loop;
print;
end loop;
 
print("Maximum value for lah(100,k):");
print(max/[lah(100,k) : k in [1..100]]);
 
op fac(n);
return */{1..n};
end op;
 
proc lah(n,k);
case of
(n=k): return 1;
(n=0 or k=0): return 0;
(k=1): return fac n;
else return (fac n*fac (n-1)) div
(fac k*fac (k-1)) div
fac (n-k);
end case;
end proc;
end program;</syntaxhighlight>
{{out}}
<pre> 1
0 1
0 2 1
0 6 6 1
0 24 36 12 1
0 120 240 120 20 1
0 720 1800 1200 300 30 1
0 5040 15120 12600 4200 630 42 1
0 40320 141120 141120 58800 11760 1176 56 1
0 362880 1451520 1693440 846720 211680 28224 2016 72 1
0 3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1
0 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1
0 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
Maximum value for lah(100,k):
44519005448993144810881324947684737529186447692709328597242209638906324913313742508392928375354932241404408343800007105650554669129521241784320000000000000000000000</pre>
 
2,115

edits

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