home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOM2
/
M2FST.LBR
/
SIEVE.MZD
/
SIEVE.MOD
Wrap
Text File
|
2000-06-30
|
1KB
|
41 lines
MODULE sieve;
(* from the Fitted Software Tools MS-DOS PD package *)
(* adapted to Turbo Modula-2 JPL 6 Sep 87 *)
(* $T- *)
FROM InOut IMPORT Read, Write, WriteString, WriteCard, WriteLn;
CONST
SIZE = 8190;
ITER = 10;
VAR
flag :ARRAY [0..SIZE] OF BOOLEAN;
i, j, k, count, prime :CARDINAL;
ch :CHAR;
BEGIN
WriteString("Hit a key to start 10 ITERATIONS");
Read(ch); WriteLn;
FOR i := 1 TO ITER DO
count := 0;
FOR j := 0 TO SIZE DO
flag[j] := TRUE;
END;
FOR j := 0 TO SIZE DO
IF flag[j] THEN
prime := j+j+3;
k := j+prime;
WHILE k <= SIZE DO
flag[k] := FALSE;
INC(k,prime);
END;
INC(count);
END;
END;
END;
Write(7C); WriteCard(count,5);
END sieve.