Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
from math import ceil
2
3
def f(n=1000000):
4
roundUp = lambda n, prime: int(ceil(float(n) / prime))
5
6
arr = [True] * n
7
arr[0] = False
8
arr[1] = False
9
primeList = []
10
11
for curr in range(2, n):
12
if not arr[curr]:
13
continue
14
primeList.append(curr)
15
for multiplicant in range(2, roundUp(n, curr)):
16
arr[multiplicant * curr] = False
17
return primeList
18
19