【笔记】欧拉计划第三题

Q:The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

A:(python)

n = int(input('input your number:\n'))
L = []
def prime_factors(n,L):
    if n <= 1:
        return 'input error'   
    for i in range(2,n+1):
        if n / i == 1:
            L.append(i)
            return L
        if n % i == 0:
            L.append(i)
            n = n // i
            return prime_factors(n, L)
print(max(prime_factors(n, L)))

你可能感兴趣的:(【笔记】欧拉计划第三题)