- , .
- .
N N!, .
, , Ctrl-Z Enter.
, , , .
N = 0 .
Program Factorial;
{$S+} { }
var
n: Integer;
Function Facfn: Integer): Real;
{ , n! }
begin {Fac}
if n < 0 then
WriteLn (' N')
else
if n = 0 then
Fac:= 1
else Fac:= n * Fac(n-l)
end {Fac};
{---------------}
begin {main} repeat
ReadLn (n);
WriteLn ('n!= ',Fac(n))
until EOF
end {main}.
, , , ( , ). : , , 8 .
, , REAL FAC EXTENDED, N = 8.
, .
EXTENDED:
Program Factorial;
{$S+,N+,E+} { }
var
n: Integer;
Function Fac(n: Integer): extended;
var
F: extended; { }
{ , ! }
begin {}
if n < 0 then
WriteLn (' N') else
if n = 0 then
Fac:= 1 else begin
F:= Fac(n-l); Fac:= F * n end end {Fac};
{--------------}
begin {main}
repeat
ReadLn (n);
WriteLn ('n! = ',Fac(n))
until EOF
end {main}.
.
, , , :
Procedure A (i: Byte);
begin
(i);
.......
end;
Procedure (j: Byte);
begin
A(j);
end;
, , .
, , :
Procedure (j: Byte); forward;
Procedure A(i: Byte);
begin
.......
(i);
.......
end;
Procedure ;
begin
.......
A(j);
.......
end;
, , , FORWARD.
- , , , .
:
, .