// Eratosthenes Sieve Benchmark uses crt; {$define FAST} const size = 8191; sqr_count = 91; var flags: array [0..size] of boolean; rtClock: byte absolute $14; {$ifdef FAST} n: word absolute $e0; k: word absolute $e2; count: word absolute $e6; {$else} n, k, count: word; {$endif} begin writeln('Mad Pascal'); writeln('Eratosthenes Sieve Benchmark'); rtClock := 0; fillchar(flags, sizeof(flags), true); for n := 2 to sqr_count do begin if flags[n] then begin k := n shl 1; while k <= size do begin flags[k] := false; Inc(k,n); end; end; end; writeln(rtClock, ' ticks'); count :=0; for n := 2 to size do begin if flags[n] then Inc(count); end; writeln(count, ' primes'); repeat until keypressed; end.