RosettaCodeData/Task/Left-factorials/PL-I/left-factorials.pli
2023-07-01 13:44:08 -04:00

23 lines
441 B
Text

lf: procedure (n) returns (fixed decimal (31) );
declare n fixed binary;
declare (s, f) fixed (31);
declare (i, j) fixed;
s = 0;
do i = n-1 to 0 by -1;
f = 1;
do j = i to 1 by -1;
f = f * j;
end;
s = s + f;
end;
return (s);
end lf;
declare n fixed binary;
do n = 0 to 10, 20 to 30;
put skip list ('Left factorial of ' || n || '=' || lf(n) );
end;
end left_factorials;