RosettaCodeData/Task/Factorial/Simula/factorial.simula

16 lines
366 B
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
begin
2018-06-22 20:57:24 +00:00
integer procedure factorial(n);
2016-12-05 22:15:40 +01:00
integer n;
begin
integer fact, i;
fact := 1;
2018-06-22 20:57:24 +00:00
for i := 2 step 1 until n do
fact := fact * i;
2016-12-05 22:15:40 +01:00
factorial := fact
end;
2018-06-22 20:57:24 +00:00
integer f; outtext("factorials:"); outimage;
for f := 0, 1, 2, 6, 9 do begin
outint(f, 2); outint(factorial(f), 8); outimage
end
2016-12-05 22:15:40 +01:00
end