Exemplo n.º 1
0
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))
Exemplo n.º 2
0
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))
Exemplo n.º 3
0
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())