home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast.iso
/
pcmag
/
vol6n20.zip
/
FIGURES.ZIP
/
FIGURE.10
< prev
next >
Wrap
Text File
|
1987-10-16
|
635b
|
23 lines
PROGRAM DoSieve;
CONST Max = 1000;
VAR Sieve : ARRAY[1..Max] OF Boolean;
I, K : Integer;
BEGIN
FillChar(Sieve, SizeOf(Sieve), True);
FOR I := 2 TO Max DIV 2 DO {Only have to go to halfway mark}
BEGIN
IF Sieve[I] THEN {IF I has not yet been eliminated}
BEGIN
K := I+I; {K starts as first multiple of I }
REPEAT
Sieve[K] := False;
K := K+I; {More multiples of I }
UNTIL K > Max;
END;
END;
WriteLn('CALCULATION COMPLETE! Primes to ',Max,' are:');
FOR I := 1 TO Max DO
IF Sieve[I] THEN
Write(I:8);
END.