def larget_prime_factor_v1(n): """ >>> larget_prime_factor_v1(6) 3 >>> larget_prime_factor_v1(8) 2 >>> larget_prime_factor_v1(13195) 29 """ return max(Prime.prime_factors(n))
def least_common_multiple_v1(maxDivisor): """ >>> least_common_multiple_v1(10) 2520 >>> least_common_multiple_v1(20) 232792560 """ primeFactorsCounter = Counter() for divisor in range(1, maxDivisor+1): # Get the union of the currently-used prime factors and the prime factors of divisor. primeFactorsCounter |= Counter(Prime.prime_factors(divisor)) return product(primeFactorsCounter.elements())