Proofs of Existence and Optimality · Constructive Proofs of Existence

Lesson 5

Nikolai Chukhin · Alexander S. Kulikov

It is not difficult to use the code provided above to find the first \(n\) for which \(p(n)\) is not prime.

from itertools import count
from sympy import isprime


def p(n):
    return n ** 2 - n + 41


print(next(n for n in count() if not isprime(p(n))))

41

If you look closely, it is not so surprising that \(p(41)\) is composite: after all, \(p(41)>41\) and \(p(41)\) is divisible by \(41\). What is surprising is that for all integers \(0 \le n < 41\), the number \(p(n)\) is prime.

For the curious 🤓
It is known that the number \(41\) is the largest Euler's lucky number. These are positive integers \(k\) such that the value of the polynomial \(n^{2}-n+k\) is prime for all integers \(0 \le n < k\).