require 'prime' T = gets.to_i X = T.times.map { gets.to_i } X.each do |x| prm = x.prime_division if prm.empty? puts 2 else counter = prm.to_h ans = Float::INFINITY Prime.each.take(12).each do |e| v = if counter[e].nil? x * e else x * (e ** (counter[e] + 1)) end ans = v if ans > v end puts ans end end