<s>[INST] Show that for any odd $n$ it follows that $n^2 \equiv 1 \mod 8$ and for uneven primes $p\neq 3$ we have $p^2 \equiv 1\mod 24$. Show that for any odd $n$ it follows that $n^2 \equiv 1 \mod 8$ and for uneven primes $p\neq 3$ we have $p^2 \equiv 1\mod 24$.
My workings so far: I proceeded by induction. Obviously $1^2 \equiv 1 \mod 8$. Then assume that for a certain uneven number $k$ we have $k^2 \equiv 1 \mod 8$. Then the the next uneven number is $k+2$ and $(k+2)^2 = k^2 + 4k + 4 \equiv 4k + 5 \mod 8$. by the induction hypothesis. Now since $k$ is uneven we can write it as $k=2j+1$ and thus $4k+5 =8j+9 \equiv 1 \mod 8$ and we have shown what was asked for by induction.
However, in the case of a prime number $n$ I am not so certain how to proceed because I can't use induction. It comes down to proving that $24|(p^2-1)$. This is certainly the case for the first uneven prime $p \neq 3$, namely $p=5$ such that $p^2-1 =24$. How would I proceed from here, or how should I approach the problem differently? Many thanks in advance!
 [/INST] If $n$ is odd, $n = 2 k + 1$ and $n^2 = 4 k^2 + 4 k + 1 = 4 k (k + 1) + 1$, and $4 k (k + 1)$ is divisible by 8. Thus $n^2 \equiv 1 \pmod{8}$.
If $p > 3$ is prime, it is odd, and so by the above $p^2 \equiv 1 \pmod{8}$. As it is prime, $p \equiv 1 \pmod{3}$ or $p \equiv 2 \pmod{3}$, so $p^2 \equiv 1 \pmod{3}$. Now, as  $\gcd(3, 8) = 1$, combining the above congruences gives $p^2 \equiv 1 \pmod{24}$.
</s>