CT094

Quadratic Primes

MediumAcceptance: 0.0%

Euler discovered the formula n^2 + n + 41 produces primes for n = 0 to 39. Another formula n^2 - 79n + 1601 produces primes for 80 consecutive values of n. Consider quadratics of the form n^2 + an + b, where |a| < A and |b| <= B. Find the product a * b for the quadratic that produces the maximum number of primes for consecutive values of n, starting from n = 0. Input format: two space-separated integers: A B

Example 1:

Input: 1000 1000
Output: -59231

Example 2:

Input: 100 100
Output: -1455

Example 3:

Input: 50 50
Output: -235

Constraints:

1 <= A, B <= 1000

Tags:

math primes quadratic number-theory
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki