nth prime number


Write a function to find the Nth prime number.

Your function should be called prime_n() and should take as input a single integer value and should return a single integer value representing the nth prime number.

The first five prime numbers are: 2, 3, 5, 7, 11. So the 3rd prime number is 5, the 5th prime number is 11, etc.

Do not use a function you find on the internet or a built-in function (such as in SymPy) to test primeness. The purpose of this exercise is for you to write your own code.

You can however use the isprime function in Sympy as a check to make sure your own code works—prime(n) returns the nth prime number:

from sympy.ntheory import prime
for i in range(1,11):
    print(f"the {i:2d}th prime number is: {prime(i):4d}")
the  1th prime number is:    2
the  2th prime number is:    3
the  3th prime number is:    5
the  4th prime number is:    7
the  5th prime number is:   11
the  6th prime number is:   13
the  7th prime number is:   17
the  8th prime number is:   19
the  9th prime number is:   23
the 10th prime number is:   29

sample solution