Here's a Python function that returns the nth prime number:
main.py553 chars18 linesThe function first initializes a list, prime_list, with the first prime number, 2. It then starts iterating through odd numbers, evaluating each one to check if it's prime. If a number is prime, it's added to prime_list. The iteration continues until prime_list has n prime numbers. Finally, the function returns the last element (prime_list[-1]) which is the nth prime number.
gistlibby LogSnag