Guest User

Untitled

a guest
Jul 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import math, pickle
  2.  
  3. num = int(raw_input('num: '))
  4.  
  5. list = range(0,num+1)
  6. p = 2
  7. i = 4
  8. while p <= math.sqrt(num):
  9.     while True:
  10.         try:
  11.             list[i] = 0
  12.             i += p
  13.         except IndexError:
  14.             break
  15.         while True:
  16.             p += 1
  17.             if list[p] != 0:
  18.                 break
  19.         i = p+p
  20.  
  21. list[1] = 0
  22. list = [x for x in list if x != 0]
Add Comment
Please, Sign In to add comment