home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turbo Toolbox
/
Turbo_Toolbox.iso
/
1991
/
04
/
review
/
sievetay.mod
< prev
next >
Wrap
Text File
|
1991-01-04
|
979b
|
43 lines
(* $Optimize:Speed $LoadTimeInit- $Large- *)
MODULE SieveTaylor;
FROM InOut IMPORT Read, Write, WriteString, WriteCard, WriteLn;
CONST
Size = 8190;
ITER = 2000;
VAR
flag :ARRAY [0..Size] OF BOOLEAN;
ch :CHAR;
count :CARDINAL;
PROCEDURE SieveTest;
VAR i, j, k, prime :CARDINAL;
BEGIN
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;
END SieveTest;
BEGIN
WriteString("Hit a key to start 2000 ITERATIONS");
Read(ch); WriteLn;
SieveTest;
Write(7C); WriteCard(count,5);
END SieveTaylor.