📅  最后修改于: 2022-03-11 14:47:05.232000             🧑  作者: Mango
# sieve of eratosthenes
def SieveOfEratosthenes(n):
prime = [True for i in range(n + 1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * 2, n + 1, p):
prime[i] = False
p += 1
prime[0] = False
prime[1] = False
r = []
for p in range(n + 1):
if prime[p]:
r.append(p)
return r
n = int(input("Get primes in range of?- "))
listOfPrime = SieveOfEratosthenes(n)
count = 1
# print primes 1-100 then 101-200 etc. in different line
for i in listOfPrime:
if i > 100 * count:
count += 1
print()
print(i, end = " ")