#7: 10001st prime | Ben Cunningham

#7: 10001st prime

Problem by Project Euler · on December 28, 2001

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 10001st prime number?

Python

def is_prime(x):

    if x < 4:
        return True

    if x % 2 == 0:
        return False

    for fac in range(3, int(x ** (1/2.0)) + 1, 2):
        if x % fac == 0:
            return False

    return True
    
count = 1
n = 3
while count < 10001:
    if is_prime(n):
        ans = n
        count += 1
    n += 2
    
print(ans)
## 104743