Primes which contain only one odd digit: Difference between revisions

Added Quackery.
(Added Quackery.)
Line 890:
Found 46,708 one odd digit primes < 100,000,000
Found 202,635 one odd digit primes < 1,000,000,000
</pre>
 
=={{header|Quackery}}==
 
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
 
<code>evendigits</code> returns the nth number which has only even digits and ends with zero. There are self-evidently 5^5 of them less than 1000000.
 
<syntaxhighlight lang="Quackery"> [ [] swap
[ 5 /mod
rot join swap
dup 0 = until ]
drop
0 swap witheach
[ swap 10 * + ]
20 * ] is evendigits ( n --> n )
 
[]
5 5 ** times
[ i^ evendigits
' [ 1 3 5 7 9 ] witheach
[ over +
dup isprime iff
[ rot swap join swap ]
else drop ]
drop ]
dup say "Qualifying primes < 1000:"
dup findwith [ 999 > ] [ ]
split drop unbuild
1 split nip -1 split drop
nest$ 44 wrap$ cr cr
say "Number of qualifying primes < 1000000: "
size echo</syntaxhighlight>
 
{{out}}
 
<pre>Qualifying primes < 1000:
3 5 7 23 29 41 43 47 61 67 83 89 223 227 229
241 263 269 281 283 401 409 421 443 449 461
463 467 487 601 607 641 643 647 661 683 809
821 823 827 829 863 881 883 887
 
Number of qualifying primes < 1000000: 2560
</pre>
 
1,462

edits