require 

magnanimouses = Enumerator.new do |y|
  (0..).each {|n| y << n if (1..n.digits.size-1).all? {|k| n.divmod(10**k).sum.prime?} }
end

puts 
puts magnanimouses.first(45).join(' ')

puts 
puts magnanimouses.first(250).last(10).join(' ')

puts 
puts magnanimouses.first(400).last(10).join(' ')