Category : Pascal Source Code
Archive   : TPTC17TC.ZIP
Filename : SIEVE.PAS

 
Output of file : SIEVE.PAS contained in archive : TPTC17TC.ZIP

(*
* Sieve of Eratosthenes
*)

program Sieve;

const
Size = 8190;
var
Flags : array[0..Size] of Boolean;
Prime, K, Count : Integer;
Inter, I : Integer;

begin
WriteLn('Sieve of Eratosthenes...');
Write('50 iterations');
WriteLn;
for Inter := 1 to 50 do
begin
Count := 0;
for I := 0 to Size do
Flags[I] := True;
for I := 0 to Size do
begin
if (Flags[I]) then
begin
Prime := I+I+3;
K := I+Prime;
while (K <= Size) do
begin
Flags[K] := False;
K := K+Prime;
end;
Count := Count+1;
end;
end;
end;
WriteLn(Count, ' primes');
end.


  3 Responses to “Category : Pascal Source Code
Archive   : TPTC17TC.ZIP
Filename : SIEVE.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/