RosettaCodeData/Task/Compile-time-calculation/PL-I/compile-time-calculation-1.pli
2023-07-01 13:44:08 -04:00

26 lines
433 B
Text

/* Factorials using the pre-processor. */
test: procedure options (main);
%factorial: procedure (N) returns (fixed);
declare N fixed;
declare (i, k) fixed;
k = 1;
do i = 2 to N;
k = k*i;
end;
return (k);
%end factorial;
%activate factorial;
declare (x, y) fixed decimal;
x = factorial (4);
put ('factorial 4 is ', x);
y = factorial (6);
put skip list ('factorial 6 is ', y);
end test;