Let $n$ and $m$ be integers such that $5$ divides $1+2n^2+3m^2.$ Then show that $5$ divides $n^2-1.$ 
Let $n$ and $m$ be integers such that $5$ divides $1+2n^2+3m^2.$ Then show that $5$ divides $n^2-1.$

$\textbf{My attempts} :$
From the condition, we can write $$1+2n^2+3m^2\equiv 0(\mod 5)\tag 1$$
Now, since $5$ is prime so by Fermat's little theorem, we can write $$n^4\equiv 1(\mod 5)\quad\text{and} \quad m^4\equiv 1(\mod 5).$$
So, we get $n^4-m^4\equiv 0(\mod 5)$.
Since $5$ prime so, either $5|(m^2+n^2)$ or $5|(m^2-n^2).$
Now if $5|(m^2+n^2)$ then from $(1)$ we get $$1-n^2+3n^2+3m^2\equiv 0(\mod 5)$$ So, we are done.
Now, if $5|(m^2-n^2)$ then from $(1)$ we get $$1+5n^2-3n^2+3m^2\equiv 0(\mod 5).$$ So, we shall arrive at a contradiction that $1\equiv 0(\mod 5).$
In this way, I have tried to solve this problem. I will be highly obliged if you kindly check this or correct me.
Thanks in advance.
 A: squares are $0,1,4 \pmod 5$   so $3m^2 \equiv 0,3,2 \pmod 5,$ next $1+3m^2 \equiv 1,4,3 \pmod 5$ Finally
$$ -(1+3m^2)  \equiv 4,1,2 \pmod 5 \; , \; \;  $$
$$  2 n^2 \equiv 0,2,3 \pmod 5 $$
The overlap of these two lists, $4,1,2$  and $0,2,3$  is the single possibility $2.$  That is, we need $2n^2 \equiv 2 \pmod 5$ and $n^2 \equiv 1 \pmod 5$
A: You can make it a bit easier. The cool thing working $\mod 5$ is that squares are always $\equiv 0$ or $\equiv \pm 1$ (you see this by just entering all possibilities). If you know that
$$
1+2n^2+3m^2 \equiv 0 \mod 5
$$
test out the possibilities of $n,m \mod 5$ to see what works:
\begin{align}
n^2\equiv 0, m^2\equiv 0 \Rightarrow 1+2n^2+3m^2\equiv 1 \not\equiv 0 \\
n^2\equiv 1, m^2\equiv 0 \Rightarrow 1+2n^2+3m^2\equiv 3 \not\equiv 0 \\
n^2\equiv -1, m^2\equiv 0 \Rightarrow 1+2n^2+3m^2\equiv -1 \not\equiv 0 \\ \\
n^2\equiv 0, m^2\equiv 1 \Rightarrow 1+2n^2+3m^2\equiv 4 \not\equiv 0 \\
n^2\equiv 1, m^2\equiv 1 \Rightarrow 1+2n^2+3m^2\equiv 6 \not\equiv 0 \\
n^2\equiv -1, m^2\equiv 1 \Rightarrow 1+2n^2+3m^2\equiv 2 \not\equiv 0 \\ \\
n^2\equiv 0, m^2\equiv -1 \Rightarrow 1+2n^2+3m^2\equiv -2 \not\equiv 0 \\
n^2\equiv 1, m^2\equiv -1 \Rightarrow 1+2n^2+3m^2\equiv 0 \\
n^2\equiv -1, m^2\equiv -1 \Rightarrow 1+2n^2+3m^2\equiv -4\not\equiv 0 \\
\end{align}
By the table above you (you could also get this by systematic thinking without trying out all possibilities), you see that $n^2\equiv 1$ which means that $n^2-1\equiv 0 \mod 5$, so $n^2-1$ is divisible by $5$ if $1+2n^2+3m^2$ is (and in that case you also know that $m^2+1$ is divisible by $5$ as well)
A: If $1+2n^2+3m^2\equiv 0\pmod 5$, then $n^2\equiv m^2+2$.
Since the only squares modulo $5$ are $0,\pm 1$, the only values for $n^2$ and $m^2$ are $n^2\equiv 1\pmod 5$ and $m^2\equiv -1\pmod 5$.
