Exemple #1
0
def longest_consecutive_sum(limit):
    all_primes = generate_primes((limit + 1) / 2)
    for i in range(len(all_primes) - n):
        current = sum(all_primes[i:i+n])
        if current > largest_sum and is_prime(current):
            largest_sum = current
            bob = all_primes[i:i+n]
    return largest_sum, bob
Exemple #2
0
def n_consecutive_sum(n, all_primes):
    largest_sum = 0
    bob = []
    for i in range(len(all_primes) - n):
        current = sum(all_primes[i:i+n])
        if current > largest_sum and is_prime(current):
            largest_sum = current
            bob = all_primes[i:i+n]
    return largest_sum, bob
Exemple #3
0
def num_consecutive_primes(a, b):
    n = 0
    while is_prime(n ** 2 + a * n + b):
        n += 1
    return n
Exemple #4
0
from mathtools import is_prime, fibbo

total = 0

for i in fibbo(20):
    if is_prime(i):
        total += i

print total