n = gets.chomp.to_i is_break = false (n-100..n+100).each do |i| (2..i/2).each do |j| if i % j == 0 then puts i is_break = true break end end break if is_break end