Solution (source code)

= Solution

<Wilson's theorem> states that an <integer> $p>1$ is a <prime number> if and only if
$$
\boxed{(p-1)!\equiv-1\pmod p}.
$$
In particular this holds for every prime, including $p=2$.