Jump to content

Primes which contain only one odd digit: Difference between revisions

→‎{{header|ALGOL 68}}: Use Algol 68-primes
(→‎{{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 only one odd digit #
INT# maxsieve primethe =primes to 1 000 000; #
#PR sieve theread "primes.incl.a68" to max prime #PR
[]BOOL 1prime := maxPRIMESIEVE prime1 ]BOOL000 prime000;
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 #
PROC show total = ( INT count, INT limit, STRING name )VOID:
Line 62 ⟶ 57:
Found 2560 single-odd-digit primes upto 1000000
</pre>
 
=={{header|AWK}}==
<lang AWK>
3,045

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.