Primes whose sum of digits is 25: Difference between revisions
Content added Content deleted
(julia example) |
|||
Line 581: | Line 581: | ||
Total found: 17 |
Total found: 17 |
||
</pre> |
</pre> |
||
=== Stretch goal === |
|||
{{trans|Phix}} |
|||
<lang julia>using Primes, Formatting |
|||
function sum25(p::String, rm, res) |
|||
if rm == 0 |
|||
if p[end] in "1379" && isprime(parse(Int128, p)) |
|||
res += 1 |
|||
end |
|||
else |
|||
for i in 1:min(rm, 9) |
|||
res = sum25(p * string(i), rm - i, res) |
|||
end |
|||
end |
|||
return res |
|||
end |
|||
sum25("", 19, 0) |
|||
@time println("There are ", format(sum25("", 25, 0), commas=true), |
|||
" primes whose digits sum to 25 without any zero digits.") |
|||
</lang>{{out}} |
|||
<pre> |
|||
There are 1,525,141 primes whose digits sum to 25 without any zero digits. |
|||
29.377893 seconds (100.61 M allocations: 4.052 GiB, 0.55% gc time) |
|||
</pre> |
|||
=={{header|Nanoquery}}== |
=={{header|Nanoquery}}== |