Prime numbers which contain 123: Difference between revisions
Content added Content deleted
m (→{{header|Julia}}: add stretch) |
|||
Line 236: | Line 236: | ||
function containstringinbase(N, str, base, verbose = true) |
function containstringinbase(N, str, base, verbose = true) |
||
arr = filter(n -> occursin(str, string(n, base=base)), primes(N)) |
arr = filter(n -> occursin(str, string(n, base=base)), primes(N)) |
||
println("\n\nFound $(length(arr)) primes < $N which contain the string $str in base $base representation.") |
|||
verbose && foreach(p -> print(rpad(p[2], 6), p[1] % 12 == 0 ? "\n" : ""), enumerate(arr)) |
verbose && foreach(p -> print(rpad(p[2], 6), p[1] % 12 == 0 ? "\n" : ""), enumerate(arr)) |
||
end |
end |
||
Line 245: | Line 245: | ||
</lang>{{out}} |
</lang>{{out}} |
||
<pre> |
<pre> |
||
Found 46 primes < 100000 which contain the string 123 in base 10 representation. |
Found 46 primes < 100000 which contain the string 123 in base 10 representation. |
||
1123 1231 1237 8123 11239 12301 12323 12329 12343 12347 12373 12377 |
|||
12379 12391 17123 20123 22123 28123 29123 31123 31231 31237 34123 37123 |
12379 12391 17123 20123 22123 28123 29123 31123 31231 31237 34123 37123 |
||
40123 41231 41233 44123 47123 49123 50123 51239 56123 59123 61231 64123 |
40123 41231 41233 44123 47123 49123 50123 51239 56123 59123 61231 64123 |
||
Line 251: | Line 252: | ||
Found 451 primes < 1000000 which contain the string 123 in base 10 representation. |
Found 451 primes < 1000000 which contain the string 123 in base 10 representation. |
||
Found 435002 primes < 1000000000 which contain the string 123 in base 10 representation. |
Found 435002 primes < 1000000000 which contain the string 123 in base 10 representation. |