I am having difficulty finishing this proof. At first, the proof is easy enough. Here's what I have thus far:
Because $5 \nmid n$, we know $\exists q \in \mathbb{Z}$ such that $$n = 5q + r$$ where $0 < r < 4$. Note $r \neq 0$ because if $r = 0$, then $5 \mid n$. Also note that $n^2 = 25q^2 + 10qr + r^2$. Then we have four cases: when $r=1$, $r=2$, $r = 3$, and $r = 4$. This is where I run into difficulty. In each of these cases, we can prove that either $n^2 = 5k + 1$ or $n^2 = 5k - 1$ for some integer $k$, but I cannot see how to prove both for each case. Any ideas?
As a side note on how I went to prove each case, I simply plugged $r$ into the formula $n^2 = 25q^2 + 10qr + r^2$. This results in $n^2 = 25q^2 + 10q + 1$. Continuing, we get $n^2 = 5(5q^2 + 2q) + 1$, and because $5q^2 + 2q$ is still an integer, this is of the form $n^2 = 5k + 1$ for some integer $k$. But I cannot find how to make the 1 a negative to prove both cases.
As you showed, $n^2=25q^2+10qr+r^2$, where $r=1, 2, 3,$ or $4$.
When $r=1$, $n^2=25q^2+10qr+1=5(5q^2+2qr)+1=5k+1.$
When $r=2$, $n^2=25q^2+10qr+4=5(5q^2+2qr+1)-1=5k-1.$
When $r=3$, $n^2=25q^2+10qr+9=5(5q^2+2qr+2)-1=5k-1.$
When $r=4$, $n^2=25q^2+10qr+16=5(5q^3+2qr+3)+1=5k+1.$
(Note: I did not mean to imply that $k$ in one equation is the same as $k$ in another.)