Complementary factorial congruence
= Complementary factorial congruence
{title2=$h!k!\equiv(-1)^{h+1}\pmod p$}
For a <prime number> $p$ and nonnegative <integers> $h+k=p-1$, <Wilson theorem> gives $(-1)^k h!k!\equiv-1\pmod p$ by replacing the last $k$ factors of $(p-1)!$ with $-1,-2,\ldots,-k$. For odd $p$, $h,k$ have the same parity; for $p=2$, both signs have the same <residue class>. Thus $h!k!+(-1)^h\equiv0\pmod p$, including the endpoint cases $0!=1$.