TITLE: Prove that for any integer $n, n^2+4$ is not divisible by $7$.
QUESTION [8 upvotes]: The question tells you to use the Division Theorem, here is my attempt:
Every integer can be expressed in the form $7q+r$ where $r$ is one of $0,1,2,3,4,5$ or $6$ and $q$ is an integer $\geq0$.
$n=7q+r$
$n^2=(7q+r)^2=49q^2+14rq+r^2$
$n^2=7(7q^2+2rq)+r^2$
$n^2+4=7(7q^2+2rq)+r^2+4$
$7(7q^2+2rq)$ is either divisible by $7$, or it is $0$ (when $q=0$), so it is $r^2+4$ we are concerned with.
Assume that $r^2+4$ is divisible by 7. Then $r^2+4=7k$ for some integer $k$.
This is the original problem we were faced with, except whereas $n$ could be any integer, $r$ is constrained to be one of $0,1,2,3,4,5$ or $6$.
Through trial and error, we see that no valid value of $r$ satisfies $r^2+4=7k$ so we have proved our theorem by contradiction.
I'm pretty sure this is either wrong somewhere or at the very least not the proof that the question intended. Any help would be appreciated.

REPLY [2 votes]: Your proof is correct. If you know congruences then we can simplify the first half as
$$ \bmod 7\!:\,\ n\equiv r\,\Rightarrow\, n^2+4\equiv r^2+4$$
by standard Congruence Rules (Sum and Product, or Polynomial Rules).
The work in your brute-force check that $\,r^2+4\,$ has no roots can be halved by  using a balanced or signed residue system $\, r\equiv \pm\{0,1,2,3\}\,\Rightarrow\,r^2\equiv \{0,1,4,2\}\Rightarrow\,r^2+4\equiv \{4,5,1,6\}$
Alternatively, more simply $\,n^2\equiv -4\equiv 3\overset{\rm cube}\Longrightarrow\,n^6\equiv 3^3\equiv -1\,$ contra little Fermat (this is a special case of Euler's criterion for squares). $ $  [note $\,n^2\equiv 3\Rightarrow n\not\equiv 0\,$ so Fermat applies].