Primes which contain only one odd digit: Difference between revisions

Content added Content deleted
(→‎{{header|ALGOL 68}}: Use Algol 68-primes)
Line 10: Line 10:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{libheader|ALGOL 68-primes}}
<lang algol68>BEGIN # find primes whose decimal representation contains only one odd digit #
<lang algol68>BEGIN # find primes whose decimal representation contains only one odd digit #
INT max prime = 1 000 000;
# sieve the primes to 1 000 000 #
# sieve the primes to max prime #
PR read "primes.incl.a68" PR
[ 1 : max prime ]BOOL prime;
[]BOOL prime = PRIMESIEVE 1 000 000;
prime[ 1 ] := FALSE; prime[ 2 ] := TRUE;
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;
# show a count of primes #
# show a count of primes #
PROC show total = ( INT count, INT limit, STRING name )VOID:
PROC show total = ( INT count, INT limit, STRING name )VOID:
Line 62: Line 57:
Found 2560 single-odd-digit primes upto 1000000
Found 2560 single-odd-digit primes upto 1000000
</pre>
</pre>

=={{header|AWK}}==
=={{header|AWK}}==
<lang AWK>
<lang AWK>