Skip to content

Commit

Permalink
add euler050 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kailanefelix committed Oct 5, 2021
1 parent 7958c0c commit 097c348
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions euler0XX/euler050.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from primality import is_prime

limit = 1_000_000

primes = [2, *(i for i in range(3, limit, 2) if is_prime(i))]

max_sum, longest = 0, 1
for i in range(1, len(primes)):
for j in range(longest + 2, i, 2):
new_sum = sum(primes[i - j:i])
if new_sum >= limit:
break

if is_prime(new_sum):
longest = j
max_sum = new_sum

print(max_sum, longest)

0 comments on commit 097c348

Please sign in to comment.