#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU x = gets.to_i f = proc {|x, k| loop { d, m = x.divmod k; break if m != 0; x = d; }; x } x = f.call(x, 4) 3.step(x ** 0.5, 2) do |k| kk = k * k break if x < kk x = f.call(x, kk) end puts x