aboutsummaryrefslogtreecommitdiff
path: root/challenge-153/deadmarshal/pascal/ch1.pas
blob: e234652168f2dbee991e20a2586aaf6d488cb6bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
program Ch1;

{$mode objfpc}

function Factorial(N:Integer):Integer;
begin
   if(N = 0) then Factorial := 1
   else Factorial := n * Factorial(N-1);
end;

function LeftFactorial(N:Integer):Integer;
var
   Sum,I:Integer;
begin
   Sum := 0;
   for I := 0 to N-1 do
      Sum := Sum + Factorial(I);
   Result := Sum;
end;

var
   I:Integer;
begin
   for I := 1 to 10 do
      Write(LeftFactorial(I), ' ');
   
end.