📐 Wilson
An integer $p > 1$ is prime if and only if $(p-1)! \\equiv -1 \\pmod{p}$.
Proof: For prime $p$, each $a \\in \\{1, 2, \\ldots, p-1\\}$ has a unique inverse $a^{-1}$ in that set. The elements that equal their own inverse satisfy $a^2 \\equiv 1$, i.e., $a \\equiv \\pm 1$. So only $1$ and $p-1$ are self-inverse.
Thus in $(p-1)! = 1 \\cdot 2 \\cdots (p-1)$, all elements except $...
From: Disquisitiones Arithmeticae
Learn more: https://gauss-deploy.vercel.app/#/section/2
Explore all courses: https://mathacademy-cyan.vercel.app