Kwwiker

Решето Эратосфена

Jun 20th, 2021
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. n = int(input())
  2. A = [True] * (n+1)
  3. k=2
  4. while k*k<=n:
  5.   if A[k]:    
  6.     i = k*k  
  7.     while i<=n:
  8.       A[i] = False  
  9.       i+=k
  10.   k += 1
  11. for i in range (2,n+1):
  12.     if A[i]:
  13.       print(i,end=' ')
Advertisement
Add Comment
Please, Sign In to add comment