how to check nth prime in python

Solutions on MaxInterview for how to check nth prime in python by the best coders in the world

showing results for - "how to check nth prime in python"
Yassin
03 Feb 2019
1def isprime(n):
2    c=0
3    for i in range(1,n+1):
4        if(n%i==0):
5            c=c+1
6    if c==2:
7        return 1
8    else:
9        return 0
10n=int(input())
11c=0
12x=1
13while(c<=n):
14    x=x+1
15    for i in range(2,x+1):
16        if isprime(i):
17            c+=1
18print(x)   
Corina
05 Nov 2017
1x=int(input())
2n,c=1,0
3while(c<x):
4    n+=1
5    for i in range(2,n+1):
6        if(n%i==0):
7            break
8    if(i==n):
9        c=c+1
10print(n)
11