Find nth Prime Number in python?

Hi Friends
Welcome
Here i am coding for to find nth prime number?

CODE:

a = int(input("Which prime number(nth): "))
b = []
i = 2
while True:
    for j in range(2,i+1):
        if i % j == 0:
            if i == j:
                b.append(i)
            else:
                break
    i += 1
    if len(b) == a:
        break
print(str(a) + "th Prime number is: " + str(b[-1]))


------
Regards
PyKAR

Comments

Post a Comment

Popular posts from this blog

Hardy - Ramanujan Number (Magic Number) Program in Python

FLAMES CODE ON PYTHON

Count Swap for Sorting in Python