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