# Generalization of Wilson's Theorem

## Theorem

Let $n \in \Z, n > 0$ be a positive integer.

Let $p$ be a prime number.

Let $\displaystyle n = \sum_{j \mathop = 0}^k a_k p^k$ be the base $p$ presentation of $n$.

Let $p^\mu$ be the largest power of $p$ which divides $n!$, that is:

$p^\mu \mathrel \backslash n!$
$p^{\mu+1} \nmid n!$

Then:

$\dfrac {n!} {p^\mu} \equiv \left({-1}\right)^\mu a_0! a_1! \cdots a_k! \pmod p$