Primes which contain only one odd digit: Difference between revisions

(Added solution for Action!)
Line 561:
 
There are 2560 primes with only one odd digit in base 10 between 1 and 1,000,000.
</pre>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>Labeled[Cases[
NestWhileList[NextPrime,
2, # <
1000 &], _?(Total[Mod[IntegerDigits@#, 2]] ==
1 &)], "Primes < 1000 with one odd digit", Top]
Labeled[Length@
Cases[NestWhileList[NextPrime,
2, # <
1000000 &], _?(Total[Mod[IntegerDigits@#, 2]] ==
1 &)], "Number of primes < 1,000,000 with one odd digit", Top]</lang>
 
{{out}}<pre>
{Primes < 1000 with one odd digit
{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 primes < 1,000,000 with one odd digit
2560
</pre>
 
Anonymous user