require 'prime' N=gets.to_i (1..1/0.0).each{|w| if (w+1).step(N,w).none?{|e|e.prime?} and (N/w*w+1..N).none?{|e|e.prime?} p w exit end }