Answers for "sang nguyen to python"

0

sang nguyen to 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)
Posted by: Guest on September-20-2021

Python Answers by Framework

Browse Popular Code Answers by Language