Primes whose first and last number is 3: Difference between revisions
Content deleted Content added
m added the Prime Numbers category. |
m julia example |
||
Line 246:
Found 2,251 primes under 1,000,000 which begin and end with 3.
</pre>
=={{header|Julia}}==
<lang julia>using Primes
isxbyx(n, base=10, dig=3) = n ÷ prevpow(base, n) == dig && n % base == dig
p3x3(N) = [p for p in primes(N) if isxbyx(p)]
println("3x3 primes < 4000:")
foreach(p -> print(rpad(last(p), 5), first(p) % 11 == 0 ? "\n" : ""), enumerate(p3x3(4000)))
println("\nTotal 3x3 primes less than 1,000,000: ", length(p3x3(1_000_000)), ".")
</lang>{{out}}
<pre>
3x3 primes < 4000:
3 313 353 373 383 3023 3083 3163 3203 3253 3313
3323 3343 3373 3413 3433 3463 3533 3583 3593 3613 3623
3643 3673 3733 3793 3803 3823 3833 3853 3863 3923 3943
Total 3x3 primes less than 1,000,000: 2251.
</pre>
=={{header|Nim}}==
|