Ormiston triples: Difference between revisions

Content added Content deleted
m (Minor code improvement.)
Line 2,118: Line 2,118:
25 Ormiston triples before one hundred million
25 Ormiston triples before one hundred million
368 Ormiston triples before one billion</pre>
368 Ormiston triples before one billion</pre>
=={{header|Ruby}}==
<syntaxhighlight lang="ruby" line>
require 'prime'

def all_palin?(arr)
sorted = arr.first.digits.sort
arr[1..].all?{|a| a.digits.sort == sorted}
end

res = Prime.each.each_cons(3).lazy.filter_map{|ar| ar.first if all_palin?(ar)}.first(25)
res.each_slice(5){|slice| puts slice.join(", ")}

n = 1E9
res = Prime.each(n).each_cons(3).count {|ar| all_palin?(ar)}
puts "\nThere are #{res} Ormiston trios below #{n}"
</syntaxhighlight>
{{out}}
<pre>11117123, 12980783, 14964017, 32638213, 32964341
33539783, 35868013, 44058013, 46103237, 48015013
50324237, 52402783, 58005239, 60601237, 61395239
74699789, 76012879, 78163123, 80905879, 81966341
82324237, 82523017, 83279783, 86050781, 92514341

There are 368 Ormiston trios below 1000000000.0
</pre>


=={{header|Wren}}==
=={{header|Wren}}==