Advertisement
Joeytje50

Untitled

Dec 7th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. def primz(max_n):
  2.     primes = range(2,max_n+1)
  3.     index = 0
  4.     while index < len(primes):
  5.         curnum = primes[index]
  6.         primes = sorted(set(primes) - set(range(curnum*2,max_n+1,curnum)))
  7.         index += 1
  8.     return sorted(primes)
  9. print primz(1000)
  10. print len(primz(1000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement