pf=[1]
def gp(n):
pr = [1
for i in range(n + 1)]
p = 2
while (p
* p <= n):
if
(pr[p] == 1):
for
i in range(p * 2, n + 1, p):
pr[i]
= 0
p
= p + 1
pr[0]= 0
pr[1]= 0
pr[2]= 0
for p in
range(n + 1):
if
pr[p]:
pf.append(p)
gp(541)
print(pf)
No comments:
Post a Comment