For any prime $p > 3$, why is $p^2-1$ always divisible by 24?

The most elementary proof I can think of, without explicitly mentioning any number theory: out of the three consecutive numbers $p - 1$, $p$, $p + 1$, one of them must be divisible by $3$; also, since the neighbours of p are consecutive even numbers, one of them must be divisible by $2$ and the other by $4$, so their product is divisible by $3 · 2 · 4 = 24$ — and of course, we can throw $p$ out since it's prime, and those factors cannot come from it.


$p$ must be congruent either to 1,3,5,7 modulo 8. Then $p^2$ is congruent to $1$ modulo $8$ in either case. So $8$ divides $p^2-1$.

Now, $p$ is not a multiple of 3, so either $p-1$ or $p+1$ is a multiple of three. So $3$ divides $p^2-1$.

Together, it follows that 24 divides $p^2 -1 $.


$p^2-1 = (p+1)(p-1)$.

$p$ must be either $1$ or $2 \pmod 3$, so we have a factor of $3$ in the product.

And $p$ is also either $1$ or $3 \mod 4$.

Hence either $2|(p+1)$ and $4|(p-1)$ or $2|(p-1)$ and $4|(p+1)$.

Thus $8\times3= 24$ divides the product.