Adopted new convention from template
This commit is contained in:
parent
4fbb158c70
commit
8e85140d06
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Created on 18 Sep 2021
|
||||
|
||||
@ -9,7 +9,7 @@ Solution for problem 50 of Project Euler
|
||||
https://projecteuler.net/problem=50
|
||||
"""
|
||||
|
||||
from utils import timeit, list_primes, is_prime
|
||||
from utils import is_prime, list_primes, timeit
|
||||
|
||||
|
||||
@timeit("Problem 50")
|
||||
@ -19,12 +19,14 @@ def compute():
|
||||
|
||||
41 = 2 + 3 + 5 + 7 + 11 + 13
|
||||
|
||||
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
|
||||
This is the longest sum of consecutive primes that adds to a prime below
|
||||
one-hundred.
|
||||
|
||||
The longest sum of consecutive primes below one-thousand that adds to a prime,
|
||||
contains 21 terms, and is equal to 953.
|
||||
The longest sum of consecutive primes below one-thousand that adds to a
|
||||
prime, contains 21 terms, and is equal to 953.
|
||||
|
||||
Which prime, below one-million, can be written as the sum of the most consecutive primes?
|
||||
Which prime, below one-million, can be written as the sum of the most
|
||||
consecutive primes?
|
||||
"""
|
||||
|
||||
ans = 0
|
||||
@ -40,12 +42,11 @@ def compute():
|
||||
if is_prime(sum) and count > result:
|
||||
result = count
|
||||
ans = sum
|
||||
# print(sum, result)
|
||||
if sum > 1_000_000:
|
||||
break
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 50: {compute()}")
|
||||
print(f"Result for Problem 50 is {compute()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user