begin comment ////////////////////////////////////////////////////////// // NAME: PETER M. MAURER // PROGRAM: SIEVE OF ERATOSTHENES // DUE: NEVER // LANGUAGE: ALGOL 60 ALA IBM 360 ////////////////////////////////////////////////////////// ; comment DEFINE THE SIEVE DATA STRUCTURE ; integer array CANDIDATES[0:1000]; integer I,J,K; comment SET LINE-LENGTH=120,SET LINES-PER-PAGE=62,OPEN ; comment 1000 TO PROTECT AGAINST STRICT EVALUATION OF AND ; for I ≔ 0 step 1 until 1000 do begin comment EVERYTHING IS POTENTIALLY PRIME UNTIL PROVEN OTHERWISE ; CANDIDATES[I] ≔ 1; end; comment NEITHER 1 NOR 0 IS PRIME, SO FLAG THEM OFF ; CANDIDATES[0] ≔ 0; CANDIDATES[1] ≔ 0; comment START THE SIEVE WITH THE INTEGER 0 ; I ≔ 0; for I ≔ I while I < 1000 do begin comment ADVANCE TO THE NEXT UN-CROSSED OUT. ; comment THIS NUMBER MUST BE A PRIME; for I ≔ I while I < 1000 ∧ CANDIDATES[I] = 0 do begin I ≔ I+1; end; comment INSURE AGAINST RUNNING OFF THE END; if I < 1000 then begin comment CROSS OUT ALL MULTIPLES OF THE PRIME.; J ≔ 2; K ≔ J×I; for K ≔ K while K < 1000 do begin CANDIDATES[K] ≔ 0; J ≔ J + 1; K ≔ J×I; end; comment ADVANCE TO THE NEXT CANDIDATE ; I ≔ I+1; end end; comment ALL UNCROSSED OUT NUMBERS ARE PRIME; comment PRINT ALL PRIMES ; for I ≔ 0 step 1 until 999 do begin if CANDIDATES[I] ≠ 0 then begin OUTINTEGER(1,I); OUTSTRING(1,“ IS PRIME”); end end end