From 95341b61b030c9e1290f3b326cb7ec584f543aea Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 31 Aug 2014 20:21:45 +0200 Subject: moved files to higher directory after split to new repository --- 027.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 027.py (limited to '027.py') diff --git a/027.py b/027.py new file mode 100644 index 0000000..563d6af --- /dev/null +++ b/027.py @@ -0,0 +1,25 @@ +from common import sieve + +primes = sieve(10000).primes() + +def count_primes(a, b): + n = 0 + while True: + p = n**2 + a*n + b + if p not in primes: + break + n += 1 + return n + +max_count = 0 +max_pair = (0, 0) + +for a in xrange(-999, 1000): + for b in xrange(-999, 1000): + c = count_primes(a, b) + if c > max_count: + max_count = c + max_pair = (a, b) + +print max_pair[0] * max_pair[1] + -- cgit v1.2.3