program Project3_5 APPTYPE CONSOLE uses math function factorial intege

 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
program Project3_5;
{$APPTYPE CONSOLE}
uses
math;
function factorial(n:integer):int64;
var i:integer;
begin
i:=1;
if n<1 then
factorial:=1
else
factorial:=n*factorial(n-1);
end;
var a,n,x,k:integer;
var n1,n2,b:real;
begin
{repeat
write('n=');
readln(n);
a:=1*factorial(n);
n1:=exp(ln(n)*n);
n2:=exp(ln(exp(1))*(-n));
b:=n1*n2*sqrt(2*Pi*n)*(1+1/(12*n));
writeln('n= ', n , ' a= ' , a , ' b= ' , b );
until false;}
writeln('k = ');
readln(k);
for i := 1 to k do
begin
a:=1*factorial(n);
n1:=exp(ln(n)*n);
n2:=exp(ln(exp(1))*(-n));
b:=n1*n2*sqrt(2*Pi*n)*(1+1/(12*n));
writeln(i:6, '! = ', b);
end;
end.