home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
mod2tutr.zip
/
EXAMPLES.ZIP
/
CH04E3A.MOD
< prev
next >
Wrap
Text File
|
1989-01-18
|
826b
|
42 lines
(* Chapter 4 - Programming exercise 3 *)
MODULE CH04E3A;
FROM InOut IMPORT WriteString, WriteCard, WriteLn;
VAR Factorial : CARDINAL;
Count1 : CARDINAL;
Count2 : CARDINAL;
BEGIN
FOR Count1 := 1 TO 8 DO
Factorial := 1;
FOR Count2 := 1 TO Count1 DO
Factorial := Factorial * Count2;
END;
WriteString("The factorial of");
WriteCard(Count1,3);
WriteString(" is");
WriteCard(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
The factorial of 8 is 40320
*)