Can the number $2^n + n^2$ be divisible by $5$ for some natural number $n$? Can the number $2^n + n^2$ be divisible by $5$ for some natural number $n$?
I found some solutions, i.e., $n=6, n=8, n=12, n=14$ but not 18 or 20 by trial and error and somewhere I realized that the last digit of either of $2^n$ or $n^2$ should be either (6 or 4) or (9 or 1). How can I prove that the expression is divisible by 5?

Hint:
First observe that if $n\equiv 0\mod 5$, there are no solutions. Next, the non-zero squares modulo $5$ are congruent to $\pm 1$, hence if $2^n+n^2\equiv 0\bmod 5$, $\;2^n\equiv\mp 1$.
Now, by lil' Fermat, $\;2^n\equiv 2^{n\bmod 4}\mod 5$,  so that


*

*either $n\equiv \pm 1\mod 5$, which implies $n^2\equiv 1\mod 5$. The equation has a solution  if $2^n\equiv -1\mod 5\iff n\equiv 2\mod 4$.

*or  $n\equiv\pm 2\mod 5$, which implies $n^2\equiv -1\mod 5$. The equation has a solution  if $2^n\equiv 1\mod 5\iff n\equiv 0\mod 4$.


This amounts to solving the systems of congruences
$$\begin{cases}n\equiv 2\mod 4,\\n\equiv \pm 1 \mod 5\end{cases}\qquad\qquad
\begin{cases}n\equiv 0\mod 4,\\n\equiv \pm 2 \mod 5\end{cases}$$
which are solved with the Chinese remainder theorem.
