Adopted new convention from template
This commit is contained in:
parent
3fe956d388
commit
4bbfd94c64
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Created on 28 Jun 2017
|
||||
|
||||
@ -9,26 +9,29 @@ Solution for problem 7 of Project Euler
|
||||
https://projecteuler.net/problem=7
|
||||
"""
|
||||
|
||||
from utils import timeit, is_prime
|
||||
from utils import is_prime, timeit
|
||||
|
||||
|
||||
@timeit("Problem 7")
|
||||
def compute():
|
||||
"""
|
||||
# Statement
|
||||
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
|
||||
primeList = []
|
||||
while len(primeList) < 10001:
|
||||
primes = []
|
||||
while len(primes) < 10_001:
|
||||
if is_prime(number):
|
||||
primeList.append(number)
|
||||
primes.append(number)
|
||||
number += 1
|
||||
|
||||
ans = primeList[len(primeList)-1]
|
||||
ans = primes[len(primes) - 1]
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 7: {compute()}")
|
||||
print(f"Result for Problem 7 is {compute()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user