I am trying to pass some time during the COVID-19 era. I was going through my mails and found a problem. A friend of mine said her daughter had this problem in some math contest about 2-3 years ago and if I could solve it.
So find all prime numbers that divide the polynomials $n^2 + 1$ and $( n + 3 )^2 + 1.$
Now I ran it through a python program and found that the answer is $n = 5$, and the prime number is 13 and this seems to be the only answer!
I have tried to look for an analytical solution but to be honest, got nowhere :( Any help would be appreciated, thank you. And stay safe.
Let $p$ be a prime number which divides both polynomials. Since $p \mid n^2 + 1$ and $p \mid (n+3)^2 + 1 = n^2 + 6n + 10$, you also have
$$p \mid (n^2 + 6n + 10) - (n^2 + 1) = 6n + 9 = 3(2n + 3) \tag{1}\label{eq1A}$$
By Euclid's lemma, you have $p \mid 3 \implies p = 3$, or $p \mid 2n + 3$. For the first case, since all perfect squares are congruent to either $0$ or $1$ when divided by $3$, you have $n^2 + 1$ has a remainder of $1$ or $2$ and, thus, $3$ doesn't divide it. This means you must instead have
$$p \mid 2n + 3 \implies p \mid (2n + 3)^2 = 4n^2 + 12n + 9 \tag{2}\label{eq2A}$$
Also, you get
$$p \mid (4n^2 + 12n + 9) - 4(n^2 + 1) = 12n + 5 \tag{3}\label{eq3A}$$
Finally, you have from \eqref{eq2A} and \eqref{eq3A},
$$p \mid 6(2n + 3) - (12n + 5) = 13 \tag{4}\label{eq4A}$$
This shows that $p = 13$ is the only prime number which can divide both polynomials, with \eqref{eq2A} giving $2n + 3 = 13 \implies n = 5$ being where that occurs for the first time for a positive integer $n$.