Primes which contain only one odd digit: Difference between revisions
Content added Content deleted
m (→{{header|Julia}}: explanation) |
|||
Line 7: | Line 7: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
If only one digit of a prime is odd, then that odd digit is the ones place digit. We don't actually need to check for an odd first digit |
If only one digit of a prime is odd, then that odd digit is the ones place digit. We don't actually need to check for an odd first digit once we exclude 2. |
||
<lang julia>using Primes |
<lang julia>using Primes |
||
function isoneoddprime(n, base = 10) |
function isoneoddprime(n, base = 10) |
||
d = digits(n, base = base) |
d = digits(n, base = base) |
||
return |
return n != 2 && all(iseven, d[begin+1:end]) |
||
end |
end |
||