By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?


In [2]:
def nth_prime(N):
    primes_found = []
    i = 1
    while len(primes_found) < N:
        i += 1
        d = 1
        for p in primes_found:
            if i % p == 0:
                d = i / p
                break
        if d == 1:
            primes_found.append(i)
    return primes_found
nth_prime(10001)[-1]


Out[2]:
104743

In [ ]: