Project Euler #3 :
What is the largest prime factor of the number 600851475143?
…
I have accidentally written a solution which seems to work and give out right answer, but not sure how it actually works, and correctness of it.
def main():
num = 600851475143
for i in range(3, num, 2):
if num%i == 0:
print(i)
num = num/i
This gave out answer as 6857 which turned out to be right.
Please explain how does the logic work and correctness of this?
New contributor
Pranav Sagar Gangu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.