-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26c50db
commit 11a8cea
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |