Answers for "how to check nth prime in python"

1

how to check nth prime in python

def isprime(n):
    c=0
    for i in range(1,n+1):
        if(n%i==0):
            c=c+1
    if c==2:
        return 1
    else:
        return 0
n=int(input())
c=0
x=1
while(c<=n):
    x=x+1
    for i in range(2,x+1):
        if isprime(i):
            c+=1
print(x)
Posted by: Guest on October-22-2020
0

how to check nth prime in python

x=int(input())
n,c=1,0
while(c<x):
    n+=1
    for i in range(2,n+1):
        if(n%i==0):
            break
    if(i==n):
        c=c+1
print(n)
Posted by: Guest on October-22-2020

Code answers related to "how to check nth prime in python"

Python Answers by Framework

Browse Popular Code Answers by Language