Advertisement
pankovamg

Решето Эратосфена (python)

Jul 1st, 2022 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. #решето Эратосфена
  2. n = int(input())
  3. a = [1] * (n + 1)
  4. i = 2
  5. while i*i <= n:
  6.     if a[i]:
  7.         for j in range(i * i, n + 1, i):
  8.             a[j] = 0
  9.     i += 1
  10.  
  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
Advertisement