require "./euler" def integer_factorization_divisible_by_all_up_to(n) result = {} of Euler::NumType => Euler::NumType (2..n).map do |i| Euler.prime_factorization(i).each do |prime, exponent| if !result.has_key?(prime) || (exponent > result[prime]) result[prime] = exponent end end end result end def factors_to_int(factorization : Hash(Euler::NumType, Euler::NumType)) factorization.map { |prime, exponent| prime ** exponent }.product end puts factors_to_int(integer_factorization_divisible_by_all_up_to(20))