<s>[INST] Proof that $ p^2 \equiv 1 \mod{30} \vee p^2 \equiv 19 \mod{30} $ for $p>5$ Proof that $$ p^2 \equiv 1 \mod{30} \vee p^2 \equiv 19 \mod{30} $$
for $p>5$ and $p$ is prime.
$\newcommand{\Mod}[1]{\ (\mathrm{mod}\ #1)}$
My try
Let show that
$$p^2 - 1 \equiv 0 \Mod{30} \vee p^2 - 1\equiv 18 \Mod{30}$$
Let check $$p^2 -1 = (p-1)(p+1) $$
We know that (for example from here) that this is dividable by $2$ and by $3$ so by $6$
Let consider $5$ cases:
$$\exists_k p=5k \rightarrow \mbox{false because p is prime}$$
$$\exists_k p=5k+1 \rightarrow p^2 - 1 = 5k(5k+2) \rightarrow \mbox{ dividable by 6 and by 5 so we have rest 0}$$
$$\exists_k p=5k+2 \rightarrow p^2 - 1 = (5k+1)(5k+3) \rightarrow \mbox{ ??? }$$
$$\exists_k p=5k+3 \rightarrow p^2 - 1 = (5k+2)(5k+4) \rightarrow \mbox{ ??? }$$
$$\exists_k p=5k+4 \rightarrow p^2 - 1 = (5k+3)(5k+5) \rightarrow \mbox{ dividable by 6 and by 5 so we have rest 0}$$
I have stucked with $???$ cases...
 [/INST] $\ 5< p$ prime $\,\Rightarrow\, \begin{align} p&\equiv\pm1\ \ \ \ \ \pmod{\!6}\\ p&\equiv \pm1,\pm2\!\!\!\pmod{\!5}\end{align}$
$\,\Rightarrow\,\begin{align}\color{#0a0}{p^2}&\: \color{#0a0}{\equiv\, 1 \pmod{\!6}}\\ p^2&\equiv \color{#c00}{\pm1}\!\!\!\!\pmod{\!5}\end{align}\!$
$\overset{\rm CRT}\iff p^2\equiv 1,19\pmod{\!30}$
because $\ p^2\!-\!1\bmod 30 = 6\left[\color{#0a0}{\dfrac{p^2\!-\!1}{6}}\bmod 5\right] = 6\left[\dfrac{\color{#c00}{0,3}}{1}\bmod 5\right] = 0,18.\ \ \ \small\rm QED $
</s>