ProjectEuler/Problem_003.py

25 lines
587 B
Python
Raw Normal View History

2018-09-30 19:32:59 +00:00
######################################################################
# The prime factors of 13195 are 5, 7, 13 and 29.
#
# What is the largest prime factor of the number 600851475143 ?
#
######################################################################
primes = [1]
original = 600851475143
for x in range(1, int(original / 2)):
tester = 600851475143
for prime in primes:
tester /= prime
if x > tester:
break
if int(original) % x is 0:
primes.append(x)
original /= x
2018-10-09 18:25:40 +00:00
print("{}".format(primes[len(primes) - 1]))
2018-09-30 19:32:59 +00:00
# Solution: 6857