It's a Project Euler problem. What is the largest prime factor of the number 600851475143? I wrote the following code-:
def prime_factors(x):
my_list = []
for no3 in range(2, int(x)):
i = 0
if x % no3 == 0:
for a in range(1, int(no3)):
if no3 % a == 0:
i = i + 1
if i == 1:
my_list.append(no3)
print(max(my_list))
prime_factors(600851475143)
It works fine for small numbers but for a large number such as this one '600851475143' the code does not give an output, it just keeps on running. I want to know that what is the problem with this code and how can I resolve it.