50 lines
899 B
Python
50 lines
899 B
Python
from collections import Counter
|
|
from functools import reduce
|
|
|
|
def find_prime_factors(n):
|
|
factors = []
|
|
|
|
i = 2
|
|
|
|
while i <= n / i:
|
|
if n % i == 0:
|
|
factors.append(i)
|
|
n = int(n / i)
|
|
else:
|
|
i += 1
|
|
|
|
factors.append(n)
|
|
|
|
return factors
|
|
|
|
def divisible(rng):
|
|
factors = None
|
|
|
|
for num in rng:
|
|
nums = 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
|
|
# max_num = max(rng)
|
|
|
|
|
|
factors = divisible(range(1, 21))
|
|
|
|
# print(factors)
|
|
|
|
# reduce(def fnc(value, key): print(value), factors.items())
|
|
|
|
result = 1
|
|
for key, value in factors.items():
|
|
result *= key ** value
|
|
|
|
print(result)
|
|
|