-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path010-FASTER.py
More file actions
executable file
·58 lines (41 loc) · 778 Bytes
/
010-FASTER.py
File metadata and controls
executable file
·58 lines (41 loc) · 778 Bytes
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!python
problem = """
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
https://projecteuler.net/problem=10
"""
print(problem)
top = 2000000
topsqrt = top**(1/2)
primeset = [2]
possibles=[]
x=3
while x < top:
possibles.append(x)
x+=2
allremovelist=[]
x=3
while x <= topsqrt:
x=possibles.pop(0)
print(x)
primeset.append(x)
removethis=x
currentremovelist=[]
n=2
while removethis < top:
removethis=x*n
currentremovelist.append(removethis)
n+=1
l1=possibles
l2=set(currentremovelist)
l3=[y for y in l1 if y not in l2]
possibles=l3
print("")
print("foo")
runsum=0
for p in primeset:
runsum+=p
for p in possibles:
runsum+=p
print("142913828922 = right")
print(runsum)