a chanté Nguyen à Python

#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)
BreadCode