Prime numbers which contain 123: Difference between revisions

→‎{{header|ALGOL 68}}: Use ALGOL 68-primes
m (→‎{{header|Sidef}}: minor fix when `upto` is not a power of `base`)
(→‎{{header|ALGOL 68}}: Use ALGOL 68-primes)
Line 10:
 
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find primes whose decimal representation contains 123 #
INT max prime = 1 000 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( 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;
# find the appropriate primes #
# as observed by the Wren sample, the primes must have a least 4 digits #
Line 57 ⟶ 53:
Found 451 "123" primes below 1000000
</pre>
 
=={{header|AWK}}==
<lang AWK>
3,021

edits