Exemplo n.º 1
0
def get_totient_maximum_below_bound(n):
    table = [0 for i in range(n + 1)]
    primes = [i for i in eu.sieve_of_eratosthenes(n) if i != 0]
    p_se = set(primes)
    for i in range(2, len(table)):
        table[i] = i / phi(i, primes, p_se)
    return table.index(max(table[8:]))
Exemplo n.º 2
0
def get_sum_of_distinct_squarefree_nums_in_first_n_rows_of_pascal_triangle(n):
    values = set(i for row in get_first_n_rows_of_pascal_triangle(n)
                 for i in row)
    bound = math.ceil(math.sqrt(max(values)))
    primes_squares = set(i**2 for i in eu.sieve_of_eratosthenes(bound)
                         if i != 0)
    return sum(i for i in values if is_squarefree(i, primes_squares))
Exemplo n.º 3
0
def get_three_primes_with_four_digit_chained_term():
    primes = [get_key(i) for i in eu.sieve_of_eratosthenes(10000) if i > 1000]
    s = set(primes)
    dic = {p: 0 for p in s}
    for p in primes:
        dic[p] += 1
    print(len(dic))
Exemplo n.º 4
0
def x(bound):
    prims = [i for i in eu.sieve_of_eratosthenes(bound) if i != 0]
    i = 3 * 5 * 7 * 11 - 1
    last = 0
    while True:
        last += gett(i, prims)
        if last == 4:
            exit(i - 3)
        if last < 0:
            last = 0
        i += 1
Exemplo n.º 5
0
def num_of_sum_of_primes_square_cube_and_fourth_power_below_bound(n):
    primes = eu.sieve_of_eratosthenes(math.ceil(math.sqrt(n)))
    return get_number_of_sums_below_bound(n, [i for i in primes if i != 0])
Exemplo n.º 6
0
def get_sum_of_truncatable_primes_below_bound(n):
    primes = {str(i) for i in eu.sieve_of_eratosthenes(n) if i != 0}
    return sum(
        int(p) for p in primes
        if is_truncatable_prime(p, primes) and int(p) >= 23)
Exemplo n.º 7
0
def get_consecutive_prime_sum_below_bound(n):
    primes_in_order = [i for i in eu.sieve_of_eratosthenes(n) if i != 0]
    return get_longest_consecutive_prime_sum(primes_in_order)
Exemplo n.º 8
0
def get_smallest_odd_composite_that_is_not_the_sum_of_prime_and_twice_a_square(
        bound):
    primes = [i for i in eu.sieve_of_eratosthenes(bound) if i != 0]
    double_squares = [2 * i**2 for i in range(math.ceil(math.sqrt(bound / 2)))]
    odd_composites = {i + j for i in primes for j in double_squares}
    return min(i for i in range(3, bound, 2) if i not in odd_composites)
Exemplo n.º 9
0
def get_num_of_circular_primes_below_bound(n):
    primes = {str(i) for i in eu.sieve_of_eratosthenes(n) if i != 0}
    return sum(1 for i in primes if is_circular_prime(i, primes))
Exemplo n.º 10
0
def get_sum_of_primes_below_bound(bound):
    return sum(eu.sieve_of_eratosthenes(bound))
Exemplo n.º 11
0
def get_sum_of_prime_generating_integers_below_n(n):
    primes = set(eu.sieve_of_eratosthenes(n))
    return sum(i for i in range(2, 100000001, 4)
               if is_prime_generating(i, primes)) + 1
Exemplo n.º 12
0
def get_max_n_digit_pandigital_prime():
    return max(i for i in eu.sieve_of_eratosthenes(7654322)
               if i != 0 and is_pandigital(i))