Project Euler Problem 7: 10001St Prime¶
The source code for this problem can be found here.
Problem Statement¶
By listing the first six prime numbers: \(2,3,5,7,11\), and \(13\), we can see that the \(6^{th}\) prime is \(13\).
What is the \(10001^{st}\) prime number?
Solution Discussion¶
Iterate over primes using sieving techniques until we reach the \(10001^{st}\) one.
Solution Implementation¶
from itertools import islice
from lib.sequence import Primes
def solve():
""" Compute the answer to Project Euler's problem #7 """
target = 10001
primes = Primes(n_primes=target)
answer = next(islice(primes, target  1, target)) # skip ahead to the 10001^{st} prime
return answer
expected_answer = 104743

solutions.problem7.
solve
()¶ Compute the answer to Project Euler’s problem #7