Project Euler

Problem 3: Largest Prime Factor

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? Run this solution at repl.io here.

      
        test = 600851475143
        n = 2
        prime_factors = []

        while n < test:
          if test % n == 0:
            test = test / n
            prime_factors.append(n)
          else:
            n += 1
        prime_factors.append(int(test))

        print(max(prime_factors))
      
    

back to code menu