コード例 #1
0
ファイル: p027.py プロジェクト: enragednuke/dailyprogrammer
def helper(n):
	primality_list = euler_shared.list_primes(n)
	b_vals = [x for x in range(0, n - 1) if primality_list[x]]
	a_vals = list(range(-1 * (n-1), n))
	a_b = [(x, y) for x in a_vals for y in b_vals if y > abs(x)]

	mx, am, bm = 0, 0, 0
	for comb in a_b:
		a, b = comb[0], comb[1]
		i, prime_combo = 0, 0
		while True:
			if euler_shared.isprime(i*i + a*i + b):
				prime_combo += 1
				i += 1
			else:
				break
		if prime_combo > mx:
			mx, am, bm = prime_combo, a, b
	return mx, am, bm
コード例 #2
0
def helper(n):
    primality_list = euler_shared.list_primes(n)
    b_vals = [x for x in range(0, n - 1) if primality_list[x]]
    a_vals = list(range(-1 * (n - 1), n))
    a_b = [(x, y) for x in a_vals for y in b_vals if y > abs(x)]

    mx, am, bm = 0, 0, 0
    for comb in a_b:
        a, b = comb[0], comb[1]
        i, prime_combo = 0, 0
        while True:
            if euler_shared.isprime(i * i + a * i + b):
                prime_combo += 1
                i += 1
            else:
                break
        if prime_combo > mx:
            mx, am, bm = prime_combo, a, b
    return mx, am, bm
コード例 #3
0
def p010():
    primes = euler_shared.list_primes(2000000)
    return sum(x for x in range(2, 2000000) if primes[x])
コード例 #4
0
ファイル: p010.py プロジェクト: enragednuke/dailyprogrammer
def p010():
	primes = euler_shared.list_primes(2000000)
	return sum(x for x in range(2, 2000000) if primes[x])