SHARE
TWEET

Untitled

a guest Jul 16th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #nth prime number
  2. from math import sqrt
  3. def NthPrime(n) :
  4.     count = 0
  5.     MAX=1000
  6.     for i in range(2, MAX + 1) :
  7.         check = 0
  8.         for j in range(2, int(sqrt(i)) + 1) :
  9.             if i % j == 0 :
  10.                 check = 1
  11.                 break
  12.  
  13.         if check == 0 :
  14.             count += 1
  15.  
  16.         if count == n :
  17.             return i
  18.             break
  19. n=int(input())
  20. print(NthPrime(n))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top