Project Euler Problem 003

Statement

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

What is the largest prime factor of the number 600851475143 ?

Solution

Again, no explanation needed:

from CommonFunctions import is_prime
 
if __name__ == '__main__':
    i = 3
    number = 600851475143
    while number > 1:
        if is_prime(i):
            while (number % i) == 0:
                number //= i
        i += 2
    i -= 2
    print("The result is:", i)

The Python file is available for download here.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License