#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU x = gets.to_i n = 10 ** 6 2.upto(n) do |i| ii = i * i loop { d, m = x.divmod ii break if m > 0 x = d } end puts x