<s>[INST] 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.
 [/INST] 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)
</s>