Achilles numbers: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: Add Ruby) |
|||
Line 2,934: | Line 2,934: | ||
puts "\nFirst #{n} strong Achilles numbers:" |
puts "\nFirst #{n} strong Achilles numbers:" |
||
achilleses.select{|ach| achilles?(𝜑(ach)) }.first(n).each_slice(10){|s| puts "%9d"*s.size % s} |
achilleses.select{|ach| achilles?(𝜑(ach)) }.first(n).each_slice(10){|s| puts "%9d"*s.size % s } |
||
puts |
puts |
||
counts = achilleses.take_while{|ach| ach < 1000000}.map{|a| a.digits.size}.tally |
counts = achilleses.take_while{|ach| ach < 1000000}.map{|a| a.digits.size }.tally |
||
counts.each{|k |
counts.each{|k, v| puts "#{k} digits: #{v}" } |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
{{out}} |