# Project Euler

### Problem 27

Euler discovered the remarkable quadratic formula:

n² + n + 41

It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40(40 + 1) + 41 is divisible by 41, and certainly when n = 41, 41² + 41 + 41 is clearly divisible by 41.

The incredible formula  n² − 79n + 1601 was discovered, which produces 80 primes for the consecutive values n = 0 to 79. The product of the coefficients, −79 and 1601, is −126479.

n² + an + b, where |a| < 1000 and |b| < 1000

where |n| is the modulus/absolute value of n
e.g. |11| = 11 and |−4| = 4

Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n = 0.

The combination between a and b seems large at first but can be reduce using logic. First, if n = 0, then b must be a prime. Therefore, by generating a list of prime less than 1000 and include both positive and negative values, there are, 168×2 = 336, numbers to be consider for b. Second of all, consider n = 1, if b is an odd number, then b+1 will be an even number and a must also be an odd number because to generate a large number of prime, we need the final number to be odd (since only one prime is even). If absolute value of b is 2, then a must be even. Therefore, there are 1000 (including both positive and negative) values to be considered as a.