Ormiston triples: Difference between revisions
Content added Content deleted
m (→{{header|Free Pascal}}: minimal enhancement) |
(julia example) |
||
Line 207: | Line 207: | ||
82324237 82523017 83279783 86050781 92514341 |
82324237 82523017 83279783 86050781 92514341 |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|Julia}}== |
|||
Takes about 2 minutes, without the benefit of the mod 18 optimization. |
|||
<syntaxhighlight lang="julia">using Primes |
|||
dig = zeros(Int, 10) |
|||
primes10B = primes(10_000_000_000) |
|||
sort10B = map(n -> evalpoly(10, sort!(digits!(dig, n))), primes10B) |
|||
ormiston_indices = filter(i -> sort10B[i] == sort10B[i + 1] == sort10B[i + 2], |
|||
firstindex(sort10B):lastindex(sort10B) - 2) |
|||
println("First 25 Ormiston triples:") |
|||
for i in 1:25 |
|||
println(primes10B[ormiston_indices[i]:ormiston_indices[i]+2]) |
|||
end |
|||
println("\nOrmiston triples before 1 billion: ", |
|||
count(t -> primes10B[t] < 1_000_000_000, ormiston_indices)) |
|||
println("Ormiston triples before 10 billion: ", length(ormiston_indices)) |
|||
</syntaxhighlight>{{out}} |
|||
<pre> |
|||
First 25 Ormiston triples: |
|||
[11117123, 11117213, 11117321] |
|||
[12980783, 12980837, 12980873] |
|||
[14964017, 14964071, 14964107] |
|||
[32638213, 32638231, 32638321] |
|||
[32964341, 32964413, 32964431] |
|||
[33539783, 33539837, 33539873] |
|||
[35868013, 35868031, 35868103] |
|||
[44058013, 44058031, 44058103] |
|||
[46103237, 46103273, 46103327] |
|||
[48015013, 48015031, 48015103] |
|||
[50324237, 50324273, 50324327] |
|||
[52402783, 52402837, 52402873] |
|||
[58005239, 58005293, 58005329] |
|||
[60601237, 60601273, 60601327] |
|||
[61395239, 61395293, 61395329] |
|||
[74699789, 74699879, 74699897] |
|||
[76012879, 76012897, 76012987] |
|||
[78163123, 78163213, 78163231] |
|||
[80905879, 80905897, 80905987] |
|||
[81966341, 81966413, 81966431] |
|||
[82324237, 82324273, 82324327] |
|||
[82523017, 82523071, 82523107] |
|||
[83279783, 83279837, 83279873] |
|||
[86050781, 86050817, 86050871] |
|||
[92514341, 92514413, 92514431] |
|||
Ormiston triples before 1 billion: 368 |
|||
Ormiston triples before 10 billion: 4925 |
|||
</pre> |
|||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
==={{header|Free Pascal}}=== |
==={{header|Free Pascal}}=== |