Put n = 0 and the polynomial is 41. Then 43, 47, 53, 61, 71, 83, 97, 113, 131, 151 — every one of them prime, for forty values of n running from 0 to 39, the last being 39² + 39 + 41 = 1601. At n = 40 the run breaks in the most embarrassing way possible: the first link prints 1681 and the second takes its square root and prints 41, so the polynomial has produced 41². At n = 41 it prints 1763, the third link, which is 41 × 43 — the constant walking back in to claim its own multiple.
A quadratic that only fails by becoming a multiple of its own constant is not luck. Rabinowitsch proved in 1913 that n² + n + q stays prime for every n up to q − 2 exactly when the imaginary quadratic field of discriminant 1 − 4q has class number one — which is to say, when unique factorisation survives there. The six q that pass are 2, 3, 5, 11, 17 and 41, and their discriminants are −7, −11, −19, −43, −67 and −163: the Heegner numbers, the same short list that makes e^(π√163) an integer to a trillionth. Euler found a prime-rich quadratic; what he had actually found, without any way of knowing it, was the largest member of a list that took another sixty years to explain.
Answer
1681
How to read it
40² + 40 + 41 on the workbench. The second link shows it is 41², the third is the value at n = 41, and the fourth is the last prime of the run, 1601.
Source
Leonhard Euler, 1772, on the polynomial n² + n + 41; the six constants q for which n² + n + q is prime for every n below q − 1 are 2, 3, 5, 11, 17 and 41
Work it in the calculator
These links open the right calculator with this problem's numbers already typed in. The line above is what the screen should show — check it yourself.