from collections import Counter from functools import reduce import util target = 232792560 def divisible(rng): factors = None for num in rng: nums = util.find_prime_factors(num) count = Counter(nums) if (factors == None): factors = count else: for key, value in count.items(): if (not factors[key] or value > factors[key]): factors[key] = value return factors factors = divisible(range(1, 21)) result = 1 for key, value in factors.items(): result *= key ** value print(result) print(result == target)