mu chance or much chance ?

日々の戯れ言

Project Euler 7

  • 問題

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

  • 解答例
def primeNum(num):
    prime = [2]
    i = 3
    while len(prime) < num:
        for n in prime:
            if i % n == 0:
                break
        else:
            prime.append(i)
        i += 2
    return prime[-1]

print(primeNum(10001))