Improved project structure.

This commit is contained in:
2017-06-01 14:50:23 +02:00
parent 5e06b03248
commit 89f0d81598
25 changed files with 2 additions and 0 deletions

38
python/e026.py Normal file
View File

@@ -0,0 +1,38 @@
def primes(n):
""" Nice way to calculate primes. Should be fast. """
l = range(2, n + 1)
_l = []
while True:
p = l[0]
if p * p > n:
return _l + l
l = [i for i in l if i % p != 0]
_l.append(p)
def produce_prime(a, b, n, primes):
x = n*n + a*n + b
return x in primes
def f_027():
""" n^2 + a*n + b
1) b must be prime
"""
p6 = set(primes(1000000))
p3 = primes(1000)
options = [(a, b)
for a in range(1, 1000, 2)
for b in p3]
print(len(options))
for n in range(100):
options = [(a, b)
for a, b in options
if produce_prime(a, b, n, p6)]
print(options)
print(len(options))
f_027()