38 lines
700 B
Python
38 lines
700 B
Python
#!/usr/bin/env python
|
|
"""
|
|
Created on 28 Jun 2017
|
|
|
|
@author: David Doblas Jiménez
|
|
@email: daviddoji@pm.me
|
|
|
|
Solution for problem 7 of Project Euler
|
|
https://projecteuler.net/problem=7
|
|
"""
|
|
|
|
from utils import is_prime, timeit
|
|
|
|
|
|
@timeit("Problem 7")
|
|
def compute():
|
|
"""
|
|
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?
|
|
"""
|
|
|
|
number = 2
|
|
primes = []
|
|
while len(primes) < 10_001:
|
|
if is_prime(number):
|
|
primes.append(number)
|
|
number += 1
|
|
|
|
ans = primes[len(primes) - 1]
|
|
|
|
return ans
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(f"Result for Problem 7 is {compute()}")
|