dos_compilers/Microsoft Pascal v2/PRIMES.PAS

31 lines
768 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(* BYTE Benchmark, 9/81, Eratosthenes Sieve Prime Maker *)
PROGRAM prime (output); (*$DEBUG- added, of course *)
CONST
size = 8190;
VAR
flags : ARRAY [0..size] OF boolean;
i,prime,k,count,iter : integer;
PROCEDURE fillc (loc: adrmem; len: word; val: char); extern;
BEGIN
writeln ('10 iterations');
FOR iter := 1 TO 10 DO BEGIN
count := 0;
fillc (adr flags, sizeof(flags), chr(true));
FOR i := 0 TO size DO
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;
(* writeln(prime) *)
END;
END;
writeln(count,' primes')
END.