Advertisement
hasib_mo

n'th Prime

Apr 4th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. import math
  2. def is_prime(i):
  3.   sq=int(math.sqrt(i)+1)
  4.   for p in range(3,sq,2):
  5.       if i%p==0:
  6.          return 0
  7.   return 1
  8.  
  9. i=3
  10. n=1
  11. while 1>0:
  12.   if is_prime(i):
  13.        n=n+1
  14.   if n==10001:
  15.        break
  16.   i=i+2
  17. print i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement