Wilson's theorem states that $$ (p-1)! \equiv -1 \pmod{p} $$ iff $p$ is prime (note that it must be positive).