51 lines
735 B
Python
51 lines
735 B
Python
from functools import reduce
|
|
# from collections import deque
|
|
|
|
n = 2000000
|
|
# n = 100
|
|
|
|
array = list(range(3, n))
|
|
|
|
# array[0] = None
|
|
# array[1] = None
|
|
|
|
primes = []
|
|
|
|
p = 2
|
|
|
|
def next():
|
|
# num = array.popleft()
|
|
|
|
# while (num == None and len(array) > 0):
|
|
# num = array.popleft()
|
|
|
|
# return num
|
|
global array
|
|
|
|
for idx, num in enumerate(array):
|
|
idx
|
|
if (num != None):
|
|
array = array[idx + 1:]
|
|
|
|
print(num)
|
|
print(idx)
|
|
return num
|
|
|
|
while (p != None):
|
|
print(p)
|
|
primes.append(p)
|
|
|
|
count = 1
|
|
i = count * p - 1
|
|
length = len(array)
|
|
print(length)
|
|
|
|
for i in range(p - 1, length, p):
|
|
array[i] = None
|
|
|
|
p = next()
|
|
|
|
|
|
print(primes)
|
|
|