Cyclops numbers: Difference between revisions

→‎{{header|ALGOL 68}}: Use ALGOL 68-primes
m (→‎{{header|REXX}}: changed a comment.)
(→‎{{header|ALGOL 68}}: Use ALGOL 68-primes)
Line 43:
=={{header|ALGOL 68}}==
Generates the sequence.
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # show cyclops numbers - numbers with a 0 in the middle and no other 0 digits #
INT max prime = 100 000;
# sieve the primes to max prime #
PR read "primes.incl.a68" PR
[ 1 : max prime ]BOOL prime;
prime[ 1 ] := FALSE;BOOL prime[ 2= ]PRIMESIEVE :=max TRUEprime;
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( max 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 TRUE if c is prime, FALSE otherwise #
PROC have a prime = ( INT c )BOOL:
Line 193 ⟶ 189:
3680863 3970793 7190917 7250527 7310137 7540457 7630367 7690967 7750577 7820287
</pre>
 
=={{header|AWK}}==
<lang AWK>
3,037

edits