Created
August 23, 2016 22:25
-
-
Save gudnm/30d0e1d920d4f05f04e895c2a995afa7 to your computer and use it in GitHub Desktop.
Project Euler problem #35
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
n = 1000000 | |
primes = [False, False] + [True]*(n-2) | |
for i in range(2, int(n**0.5)+1): | |
if primes[i]: | |
primes[i*i::i] = [False] * len(primes[i*i::i]) | |
def check_rotations(num): | |
s = str(num) | |
return all(primes[int((s+s)[i:i+len(s)])] for i in range(len(s))) | |
print(len([True for i in range(2, n) if (primes[i] and check_rotations(i))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment