📅  最后修改于: 2022-03-11 14:46:38.901000             🧑  作者: Mango
#Cach 1: Sang true false
prime = [True] * (n+1)
prime[0] = prime[1] = False
for i in range(2, n+1):
if prime[i]:
for j in range(i*i, n+1, i):
prime[j] = False
#Cach 2: Sang ra so
prime = []
m = []
for i in range(2, n+1):
if i not in m:
prime.append(i)
for j in range(i*i, n+1, i):
m.append(j)