Skip to content

Commit

Permalink
add euler037 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kailanefelix committed Sep 28, 2021
1 parent 26c50db commit 11a8cea
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions euler0XX/euler037.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import itertools
from euler0xx.primality import is_prime

count, total = 0, 0
numbers = itertools.count(11, step=2)


def truncated(n: int):
s = str(n)
for i in range(1, len(s)):
yield int(s[i:])
yield int(s[:-i])


while count < 11:
number = next(numbers)

if is_prime(number) and all(is_prime(n) for n in truncated(number)):
count = count + 1
total = total + number

print(total)

0 comments on commit 11a8cea

Please sign in to comment.