Kwwiker

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

Jun 20th, 2021
820
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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=' ')
RAW Paste Data