31 lines
713 B
Text
31 lines
713 B
Text
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);
|
|
]
|
|
]
|