The Converse of Wilson's Theorem

Wilson's Theorem establishes that for any prime $p$, it must be true that $(p-1)! \equiv -1 \pmod{p}$, but we can also show that the converse is true. That is to say, if $n$ is some positive integer with $(n-1)! \equiv -1$, then $n$ must be prime.

To prove this, we argue indirectly...

Suppose $n$ is not prime. Then $n$ is composite and has some positive divisor $a$ with $1 \lt a \lt n$.

As $(n-1)!$ is the product of all integers between $1$ and $n$, exclusive -- it must be the case that $a$ is one of these factors, which tells us that $$a \mid (n-1)!$$

Turning our attention to the given hypothesis that $(n-1)! \equiv -1 \pmod{n}$, we see this implies $n \mid (n-1)! + 1$.

Recalling that $a$ is a presumed divisor of $n$, we must then also have $$a \mid (n-1)! + 1$$

Knowing that $a \mid (n-1)!$ and $a \mid (n-1)! + 1$ forces us to conclude that $a \mid 1$, and the only positive divisor of $n$ that satisfies this would be $a=1$. This contradicts the statement that $1 \lt a \lt n$, however.

As such, our assumption must be incorrect and its opposite must be true.

$n$ is indeed prime.