DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦fd7ce904a⟧ TextFile

    Length: 1152 (0x480)
    Types: TextFile
    Names: »SIEVE.PAS«

Derivation

└─⟦692ac107c⟧ Bits:30005923 PolyPascal-80 V3.10 arbejdsdiskette 1
    └─ ⟦this⟧ »SIEVE.PAS« 

TextFile

 (*Eratosthenes Sieve Prime number in Pascal*)
program PRIME;
CONST
  size = 8190;
VAR
   flags: ARRAY (.0..size.) OF BOOLEAN;
   i,prime, k, count,iter: INTEGER;
BEGIN
   WRITELN(rvson,' PROGRAM PRIMES,  10 gentagelser. ', rvsoff);
   FOR iter:= 1 TO 10 DO BEGIN;         (* do program 10 times          *)
      count:= 0;                        (* prime counter                *)
      FOR i:= 0 to size do              
          flags (.i.):= TRUE;           (* set flags all true           *)
        FOR i := 0 TO size DO
           IF flags (.i.) THEN BEGIN    (* found a prime                *)
        prime := i + i +3;              (* twice the index + 3          *)
        k:= i + prime;                  (* first multiple to kill       *)
        WHILE k <= size DO BEGIN
           flags (.k.):= FALSE;         (* zero a non prime             *)
           k:= k + prime;               (* next multiple                *)
        END;
        count:= count + 1               (* primes found                 *)   
      END;
   END;
   WRITELN(count, ' primes ');          (* primes found in 19th pas     *)
END.«eof»