sum = 01.upto(666554) do |n| sum += n if n.to_s.match /^[456]+$/endputs sum
Standard input is empty
409632209
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!