Suppose $$ n=a_0+a_1p+\cdots+a_kp^k\qquad 0\leq a_i
$p$ (for $p$ a prime) representation of an integer $n$. I'm trying to prove to myself that $$ ord_p(n!)=\sum_{i=1}^k a_i(1+p+\cdots+p^{i-1}). $$
I know the formula that $\displaystyle ord_p(n!)=\left\lfloor\frac{n}{p}\right\rfloor+\left\lfloor\frac{n}{p^2}\right\rfloor+\cdots$. Substituting the representation of $n$ base $p$, I find something like $$ \left\lfloor\frac{a_0}{p}+a_1+\cdots a_kp^{k-1}\right\rfloor+\cdots+\left\lfloor\frac{a_0}{p^k}+\cdots+\frac{a_{k-1}}{p}+a_k\right\rfloor+\left\lfloor\frac{a_0}{p^{k+1}}+\cdots+\frac{a_k}{p}\right\rfloor+\cdots $$ Pulling out the integer terms, this can be rewritten as $$ \left\lfloor\frac{a_0}{p}\right\rfloor+\cdots+\left\lfloor\frac{a_0}{p^{k+1}}+\cdots+\frac{a_k}{p}\right\rfloor+\cdots+\sum_{i=1}^k a_i(1+p+\cdots+p^{i-1}). $$
So I have the formula I want at the right, and it amounts to showing that all the terms on the left are actually $0$. For instance, it's clear $\left\lfloor\frac{a_0}{p}\right\rfloor=0$, but I don't know what to do for the other terms. For $\left\lfloor\frac{a_0}{p^2}+\frac{a_1}{p}\right\rfloor$, I can only bound $$ \frac{a_0}{p^2}+\frac{a_1}{p}=\frac{a_0+a_1p}{p^2}\leq\frac{p+p^2}{p^2} $$ which doesn't give anything conclusive. How can one conclude the leftmost terms are all $0$ to get the alternative formula?
Edit: I wouldn't mind seeing the alternative with induction on $n$ instead if it's less messy.