Write a function to return the nth prime number


Topic: Write a function to return the nth prime number

Solution

def nth_prime_number(n):
    prime_list = [2]
    num = 3
    while len(prime_list) < n:
        for p in prime_list:
            if num % p == 0:
                break
        else:
            prime_list.append(num)
            num += 2
    return prime_list[-1]



List all Python Programs