tutorials/pascal/Factorial.pas

20 lines
271 B
ObjectPascal

program Factorial;
var input: Word;
function Fact (n: word): NativeUInt;
begin
case n of
0: Fact := 0;
1: Fact := 1;
else Fact := n * Fact(n - 1)
end;
end;
begin
Write('Which Factorial to calculate? ');
ReadLn(input);
WriteLn(Fact(input));
end.