TITLE: Are there infinite many positive integers $n$ such that $n^2+n+41$ is composite, but not divisible by $41$?
QUESTION [8 upvotes]: Let $S=n^2+n+41$. If you try with $n=1, 2, 3, \dots, 39$, $S$ is always prime. But if $n=40, 41$, $S$ is composite. Hence, there are infinite many positive integers $n$, such that $S$ is composite. 
My question is: Are there infinite many positive integer $n$, such that $S$ is composite, but not divisible by 41?

REPLY [2 votes]: Pulling a rabbit out of a hat, note (or check) that
$$8652\equiv
\begin{cases}
1\mod41\\
163\mod653
\end{cases}$$
and 
$$163^2+163+41=163\cdot164+41=163\cdot4\cdot41+41=653\cdot41\equiv0\mod653$$
so if we let $n=(41\cdot653)k+8652=26773k+8652$, then for any $k$ we have
$$S=n^2+n+41\equiv\begin{cases}1+1+0\not\equiv0\mod41\\
163^2+163+41\equiv0\mod653
\end{cases}$$
so all these values of $S$ are composite, since they're divisible by (and strictly greater than) $653$, but not divisible by $41$.