Primes which contain only one odd digit: Difference between revisions
Content added Content deleted
(→{{header|Go}}: Added stretch goal.) |
(Added XPL0 example.) |
||
Line 275: | Line 275: | ||
There are 2,560 primes under 1,000,000 which contain only one odd digit. |
There are 2,560 primes under 1,000,000 which contain only one odd digit. |
||
</pre> |
|||
=={{header|XPL0}}== |
|||
<lang XPL0>func IsPrime(N); \Return 'true' if N is a prime number |
|||
int N, I; |
|||
[if N <= 1 then return false; |
|||
for I:= 2 to sqrt(N) do |
|||
if rem(N/I) = 0 then return false; |
|||
return true; |
|||
]; |
|||
int Count, N, Hun, Ten, One; |
|||
[Count:= 0; |
|||
for Hun:= 0 to 4 do |
|||
for Ten:= 0 to 4 do |
|||
for One:= 0 to 4 do |
|||
[N:= Hun*200 + Ten*20 + One*2 + 1; |
|||
if IsPrime(N) then |
|||
[IntOut(0, N); |
|||
Count:= Count+1; |
|||
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\); |
|||
]; |
|||
]; |
|||
CrLf(0); |
|||
IntOut(0, Count); |
|||
Text(0, " such numbers found. |
|||
"); |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
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 |
|||
45 such numbers found. |
|||
</pre> |
</pre> |