project-euler/problem3.py

19 lines
412 B
Python
Raw Normal View History

2017-06-21 16:42:24 +00:00
prime = 600851475143
2017-06-21 15:39:31 +00:00
current_num = prime
factors = []
2017-06-21 16:42:24 +00:00
ran = False
hit = False
2017-06-21 15:39:31 +00:00
2017-06-21 16:42:24 +00:00
while current_num != 1 and not ran:
2017-06-21 15:39:31 +00:00
for i in range(2,current_num + 1):
if current_num % i == 0:
print('got a hit: ' + str(current_num) + str(factors))
factors.append(i)
2017-06-21 16:42:24 +00:00
current_num //= i
hit = True
if not hit:
ran = False
2017-06-21 15:39:31 +00:00
print(factors)
2017-06-21 16:42:24 +00:00
print('the largest prime factor is: ' + str(max(factors)))