Thursday, April 23, 2020

PRIME.P

[Table of Contents]

PRIME.P is a sample program that resides on the Kyan Pascal 2.x Disk 2. I assume that this sample program is mostly used in bench marking tests, to compare how fast different Pascal versions (for example, the Atari Pascal Language System PRIMES), different languages, and/or different platforms run.

Source Code


PROGRAM Prime;
CONST Size=8190;
VAR
  f: ARRAY[0..Size] OF Boolean;
  i,k,prime,count: Integer;
BEGIN
  Writeln('1 iteration');
  count:=0;
  FOR i:=0 TO Size DO f[i]:=TRUE;
  FOR i:=0 TO Size DO
   IF f[i] THEN BEGIN
    prime:=i+i+3;
    (* writeln(prime); *)
    k:=i+prime;
    WHILE K<=Size DO BEGIN
      f[k]:=FALSE;
      k:=k+prime;
    END;
    count:=count+1
   END;
  Writeln(count,' primes')
END.

Sample Run




No comments:

Post a Comment