MODULE fact0; (*--------------------------------------------------------- File name: fact0.pm Author: AG, MM Date: 5/19/05 Problem: This program calculates factorial sequentially. No configuration is defined, everything is calculated trought the controller Example of Execution: Enter N?: 5 N! = 120 Cycles: N multiplications. *) (*---------------------------------------------------------- VARIABLES ----------------------------------------------------------*) VAR N, K, Fact : INTEGER; (*---------------------------------------------------------- MAIN ----------------------------------------------------------*) BEGIN (*initializing data *) Fact:=1; (*printing *) WriteString("Enter N?: "); ReadInt(N); (* Read N *) FOR K:=1 TO N DO Fact:= Fact*K; END; (*FOR *) (*printing*) WriteString(" N! = " ); WriteInt(Fact, 2); END fact0.