<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] Any prime $> 5$ is congruent to $1$ mod $2$, to $1$ or $2$ mod $3$, and to $1, 2, 3$ or $4$ mod $5$.
Its square is congruent to $1$ mod $2$, to $1$ mod $3$, and to $1$ or $4$ mod $5$.  The numbers that are congruent to $1$ mod $2$, to $1$ mod $3$ and to $1$ mod $5$ are congruent to $1$ mod $30$, while those that are congruent to $1$ mod $2$, to $1$ mod $3$ and to $4$ mod $5$ are congruent to $19$ mod $30$ (see Chinese Remainder Theorem).
</s>