Wilson's Theorem/Sufficient Condition

Theorem
Let $p$ be a (strictly) positive integer such that:
 * $\paren {p - 1}! \equiv -1 \pmod p$

Then $p$ is a prime number.

Proof
Assume $p$ is composite, and $q$ is a prime such that $q \divides p$.

Then both $p$ and $\paren {p - 1}!$ are divisible by $q$.

If the congruence $\paren {p - 1}! \equiv -1 \pmod p$ were satisfied, we would have $\paren {p - 1}! \equiv -1 \pmod q$.

However, this amounts to $0 \equiv -1 \pmod q$, a contradiction.

Hence for $p$ composite, the congruence $\paren {p - 1}! \equiv -1 \pmod p$ cannot hold.

Also known as
Some sources refer to this theorem as the Wilson-Lagrange theorem, after, who proved it.