home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
m2t-2.zip
/
ANSWERS
/
CH04E3B.MOD
< prev
next >
Wrap
Text File
|
1989-01-18
|
817b
|
42 lines
(* Chapter 4 - Programming exercise 3 *)
MODULE CH04E3A;
FROM InOut IMPORT WriteString, WriteInt, WriteLn;
VAR Factorial : INTEGER;
Count1 : INTEGER;
Count2 : INTEGER;
BEGIN
FOR Count1 := 1 TO 8 DO
Factorial := 1;
FOR Count2 := 1 TO Count1 DO
Factorial := Factorial * Count2;
END;
WriteString("The factorial of");
WriteInt(Count1,3);
WriteString(" is");
WriteInt(Factorial,6);
WriteLn;
END;
END CH04E3A.
(* Result of execution
The factorial of 1 is 1
The factorial of 2 is 2
The factorial of 3 is 6
The factorial of 4 is 24
The factorial of 5 is 120
The factorial of 6 is 720
The factorial of 7 is 5040
------> integer overflow
*)