The Project Euler #3 asks for the largest prime factor of a given number, which I have named num2
.
I have already solved this problem using:
i = 2
while num2 != 1:
if num2 % i == 0:
num2 /= i
else:
i += 1
print(i)
But I found this code that I cannot understand:
i = 2
while num2 > i ** 2:
while num2 % i == 0:
num2 = num2 // i
i = i + 1
print(num2)
Can someone explain to me why it checks for num2 > i * i
?