|  | DataMuseum.dkPresents historical artifacts from the history of: Christian Rovsing CR7, CR8 & CR16 CP/M | 
This is an automatic "excavation" of a thematic subset of
 See our Wiki for more about Christian Rovsing CR7, CR8 & CR16 CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. | 
top - metrics - download
    Length: 1280 (0x500)
    Types: TextFile
    Names: »PRIMES.PAS«
└─⟦6bdda2365⟧ Bits:30005253 COMPAS Pascal v2.21 til CR7
    └─⟦this⟧ »PRIMES.PAS« 
PROGRAM PRIMES; æ$R-å
æ This program will calculate and display all prime numbers å
æ between 1 and 30000. The algorithm of the program is to   å
æ start out with an array containing representatives for    å
æ all odd numbers between 3 and 29999. Starting from 3 and  å
æ working upwards, each odd number is then tested. If a     å
æ number is still a member of the list when it is tested,   å
æ it is a prime number, and thus it is printed, and all odd å
æ multiples of the number are eliminated from the list. As  å
æ can be expected, the program is quite slow on calculating å
æ the very first primes, but from then on it gets faster    å
æ and faster. Note that 1 and 2 are assumed to be primes,   å
æ and not actually calculated.				    å
CONST
  MAX2 = 15000;   æ MAXPRIME/2 å
  MAX3 = 10000;   æ MAXPRIME/3 å
VAR
  I,J,K: INTEGER;
  TEST: ARRAYÆ2..MAX2Å OF BOOLEAN;
BEGIN
  WRITE(1:8,2:8);
  FOR I:=2 TO MAX2 DO TESTÆIÅ:=TRUE;
  FOR I:=2 TO MAX2 DO
  IF TESTÆIÅ THEN
  BEGIN
    J:=I+I-1; WRITE(J:8);
    IF J<MAX3 THEN
    BEGIN
      K:=I+J;
      WHILE K<=MAX2 DO
      BEGIN
	TESTÆKÅ:=FALSE; K:=K+J;
      END;
    END;
  END;
  WRITELN;
END.
«eof»