def numbers_with_three(a, b) a.upto(b) do |n| if n % 3 == 0 puts n next end n.digits.each do |m| if m == 3 puts n break end end end end a, b = gets.split.map(&:to_i) numbers_with_three(a,b)