Example #1
0
def pe41():
    """
    >>> pe41()
    7652413
    """
    primes = Primes(1000000)
    for perm in permutations(range(7, 0, -1)):
        n = list_num(perm)
        if primes.is_prime(n):
            return n
    return -1
Example #2
0
def pe43():
    """
    >>> pe43()
    [1406357289, 1430952867, 1460357289, 4106357289, 4130952867, 4160357289]
    """
    # s = 0
    ps = []
    for perm in permutations(i for i in range(10) if i != 5):
        if perm[3] & 1: continue
        perm = list(perm)
        perm.insert(5, 5)
        if not list_num(perm[7:10]) % 17 and \
           not list_num(perm[6: 9]) % 13 and \
           not list_num(perm[5: 8]) % 11 and \
           not list_num(perm[4: 7]) %  7 and \
           not list_num(perm[3: 6]) %  5 and \
           not list_num(perm[2: 5]) %  3:
            # s += list_num(perm)
            ps.append(list_num(perm))
    # print(s)
    return ps
Example #3
0
def pe43():
    """
    >>> pe43()
    [1406357289, 1430952867, 1460357289, 4106357289, 4130952867, 4160357289]
    """
    # s = 0
    ps = []
    for perm in permutations(i for i in range(10) if i != 5):
        if perm[3] & 1: continue
        perm = list(perm)
        perm.insert(5, 5)
        if not list_num(perm[7:10]) % 17 and \
           not list_num(perm[6: 9]) % 13 and \
           not list_num(perm[5: 8]) % 11 and \
           not list_num(perm[4: 7]) %  7 and \
           not list_num(perm[3: 6]) %  5 and \
           not list_num(perm[2: 5]) %  3:
            # s += list_num(perm)
            ps.append(list_num(perm))
    # print(s)
    return ps