I was working on Euler Project problems, this is problem five:
Largest prime factor Problem 3 The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
I got the working code:
def factor(x, f=2):
while x >= f*f:
while x % f == 0:
x = int(x/f)
factor = f
f += 1
print(f'x = {x},\nlast factor = {factor}') # print for debug only
return max(x, factor)
factor(19*19*19*19*19*19*19*19*19*1999989899)
x = 33170854034208712, last factor = 182128674
33170854034208712
Does anyone know why this failed to yield the right answer?