Example #1
0
def solution():

    primes =  [p for p in prime_numbers.primes(10000) if p > 1000]

    for p in primes:
        p_set = set(base10.perms(p)) & set(primes)
        p_list = sorted(list(x for x in p_set if x > p))

        for q in p_list:
            if (2*q-p) in p_list:
                print(p,q,2*q-p)

    return 'done'
Example #2
0
def solution():

    primes = set(prime_numbers.primes(10000000))
    count = 0
    running_total = 0
    i = 2
    while count < 11 and i < 12:

        ndigit_candidates = candidates(i)
        for x in ndigit_candidates:
            if prime_numbers.is_prime(t_set(x)):
                print(x)
                count = count + 1
                running_total = running_total + x
        i = i + 1

    return running_total
Example #3
0
import prime_numbers
import itertools

primes = set(prime_numbers.primes(2100000))


def number_of_consecutive_primes(a, b):
    """returns the number of consecutive primes produced by the polynomial n^2 + an + b"""

    n = 0
    while (n ** 2 + a * n + b) in primes:
        n = n + 1

    return n


def solution(m=1000):
    """returns the maximum number of consecutive primes returned by a quadratic polynomial with x and number coefficents of modulus less than m"""

    n = 0
    for (a, b) in itertools.product(range(-m + 1, m), primes.intersection(range(2, m))):
        x = number_of_consecutive_primes(a, b)
        if x > n:
            n = x
            max_a = a
            max_b = b

    print(max_a, max_b)
    return max_a * max_b