Pierpont primes: Difference between revisions

(→‎{{header|jq}}: one too many debug statements)
Line 31:
=={{header|ALGOL 68}}==
As in the second Go sample, generates the 3-smooth number sequence to find Pierpoint Prime candidates. Uses a sliding window on the sequence to avoid having to keep it all in memory.
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find some pierpoint primes of the first kind (2^u3^v + 1) #
# and second kind (2^u3^v - 1) #
# construct a sieve of primes up to 10 000 #
PR read "primes.incl.a68" PR
[ 1 : 10 000 ]BOOL prime;
prime[ 1 ] := FALSE;10 000 ]BOOL prime[ 2= ]PRIMESIEVE :=10 TRUE000;
FOR i FROM 3 BY 2 TO UPB prime DO prime[ i ] := TRUE OD;
FOR i FROM 4 BY 2 TO UPB prime DO prime[ i ] := FALSE OD;
FOR i FROM 3 BY 2 TO ENTIER sqrt( UPB prime ) DO
IF prime[ i ] THEN FOR s FROM i * i BY i + i TO UPB prime DO prime[ s ] := FALSE OD FI
OD;
# returns the minimum of a and b #
PROC min = ( INT a, b )INT: IF a < b THEN a ELSE b FI;
3,043

edits