예제 #1
0
# This should be self-explanatory.

# Output: 7652413

import itertools
from eulerutils import is_prime

if __name__ == "__main__":
    # it can't be 8 or 9 digits since any 8 or 9 digit pandigital is
    # divisble by 3
    perms = itertools.permutations(range(1,8)[::-1])
    for perm in perms:
        num = int("".join(str(x) for x in perm))
        if is_prime(num):
            print(num)
            break
예제 #2
0
# This should be self-explanatory.

# Output:

from eulerutils import is_prime, prime_gen

def rotations(s):
    res = []
    for i in range(len(s)):
        res.append(s[i:] + s[:i])
    return res

if __name__ == "__main__":
    count = 0
    for p in prime_gen():
        if p > 1000000:
            break
        circular = True
        rots = [int(i) for i in rotations(str(p))]
        for rot in rots:
            if not is_prime(rot):
                circular = False
                break
        if circular:
            count += 1
    print(count)