home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
turbom2
/
m2dsieve.lbr
/
DSIEVE.MZD
/
DSIEVE.MOD
Wrap
Text File
|
1987-08-30
|
1KB
|
61 lines
MODULE DSieve;
(*
Sieve test with ten iterations
Adapted from MTSIEV10.MOD, author unknown
Demonstrates use of DStime Procedures
Jim Lill 29 Aug 87
*)
FROM DStime IMPORT CLOCK,MIN,SEC;
CONST
SIZE = 7000;
VAR
et, I, PRIME, K, COUNT, ITER, min, sec : CARDINAL;
time : BOOLEAN;
FLAGS: ARRAY [0..SIZE] OF BOOLEAN;
BEGIN
time:= CLOCK();
min:= MIN(); sec:= SEC();
WRITELN('Start Ten Iterations');
FOR ITER := 1 TO 10 DO
COUNT := 0;
FOR I := 0 TO SIZE DO
FLAGS[I] := TRUE
END;
FOR I := 0 TO SIZE DO
IF FLAGS[I] THEN
PRIME := I+I+3;
K := I+PRIME;
WHILE K <= SIZE DO
FLAGS[K] := FALSE;
INC(K, PRIME)
END;
INC(COUNT)
END
END;
END;
time:= CLOCK();
WRITE(COUNT:0);
WRITE(' Primes, ');
min:= MIN() - min; sec:= SEC() - sec;
et:= sec + (60 * min);
WRITELN('Time Required= ',et:0,' Seconds')
END DSieve.