Problem 7

Problem 7

# Problem_7.py
"""
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?
第10001个质数是什么?
质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数。
"""
primes = []

for i in range(2, 999999):
    flag = True
    for x in range(2, i):
        if i % x == 0:
            flag = False
            break
    if flag:
        print(i)
        primes.append(i)
    if len(primes) == 10001:
        break

print(primes)
print(primes[-1])
Resistance is Futile!
原文地址:https://www.cnblogs.com/noonjuan/p/10957367.html