n = gets.to_i nh = Math.sqrt(n).to_i 3.upto(nh) do |x| if n % x == 0 puts x break end end puts n