题目:https://projecteuler.net/problem=7
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?
此题目还是考察质数的判断方法,用MATLAB比较简单
>> feval(@(x)x(10001),primes(2e5))
ans =
104743
下面是Python实现
primes = [2]
t = 2
while len(primes) <= 10000:
t += 1
isprime = True
for i in primes:
if t%i == 0:
isprime = False
break
if not(isprime):
continue
primes.append(t)
print(primes[-1])