-
Notifications
You must be signed in to change notification settings - Fork 0
/
euler47.py
42 lines (33 loc) · 809 Bytes
/
euler47.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
f=open('primes.txt')
import pickle
primes=pickle.loads(f.read())
d=dict()
for x in primes:
d[x]=1
def factorize(x):
factors=[]
while x != 1:
for y in primes:
if x==1:
return factors
if x%y==0:
factors.append(y)
while x%y ==0:
x=x/y
return factors
def find():
n=10
while n<1000000:
print n
if n in d or n+1 in d or n+2 in d or n+3 in d:
n+=1
elif len(factorize(n))!=4:
n+=1
elif len(factorize(n+1))!=4:
n+=1
elif len(factorize(n+2))!=4:
n+=1
elif len(factorize(n+3))!=4:
n+=1
else:
return (n,n+1,n+2,n+3)