Factorial Divisible by Prime Power

Theorem
Let $n \in \Z: n \ge 1$.

Let $p$ be a prime number.

Let $n$ be expressed in base $p$ notation:
 * $\displaystyle n = \sum_{j=0}^m r_j p^j$

where $0 \le r_j < p$.

Let $n!$ be the factorial of $n$.

Let $p^\mu$ be the largest power of $p$ which divides $n!$, that is:
 * $p^\mu \backslash n$
 * $p^{\mu+1} \nmid n$

Then:
 * $\displaystyle \mu = \frac {n - s_p \left({n}\right)} {p-1}$

where $s_p \left({n}\right)$ is the digit sum of $n$.

Proof
If $p > n$, then $s_p \left({n}\right) = n$ and we have that:
 * $\displaystyle \frac {n - s_p \left({n}\right)} {p-1} = 0$

which ties in with the fact that $\displaystyle \left \lfloor{\frac n p}\right \rfloor = 0$.

Hence the result holds for $p > n$.

So, let $p \le n$.

From Multiplicity of Prime Factor in Factorial, we have that:

where $p^s < n < p^{s+1}$.

From Quotient and Remainder to Number Base, we have that:
 * $\displaystyle \left \lfloor{\frac n {p^k}}\right \rfloor = \left[{r_m r_{m-1} \ldots r_{k+1} r_k}\right]_p = \sum_{j=0}^{m-k} r_j p^j$

where $0 \le r_j < p$.

Hence:

Hence the result.

History
This result is due to Adrien-Marie Legendre, who published it in Essai sur la Théorie des Nombres (2nd edition) in 1808.