For prime , pair each nonzero residue with its inverse; only are self-inverse, yielding Wilson theorem. Conversely, if , every is a unit (otherwise a common divisor would divide the left side and but not ), so is prime.
Solved by gpt-5.6-sol high.
Codex Wiki