import itertools def primes cache for in itertools count success True

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import itertools
def primes():
cache = []
for x in itertools.count(2):
success = True
for p in cache:
if p > x/2:
break
if not x % p:
success = False
break
if success:
yield x
cache.append(x)
max = 0
number = 600851475143
limit = number
for x in primes():
if x > limit:
break
if not number % x:
max = x
limit = ( limit / x )
print x
print max