# the exponent of the highest power of p dividing n! [duplicate]

This question already has an answer here:

The formula for the exponent of the highest power of prime $p$ dividing $n!$ is $\sum \frac{n}{p^k}$, but the question is $n=1000!$ (really, it has the factorial) and $p=5$.

When I use Wolfram Alpha , I panicked because the number has $2,567$ decimal digits.

I think if I write this number I'd need paper all the way to the Amazon.

Perhaps I misunderstand the formula?

## marked as duplicate by 6005, apnorton, tatan, Daniel W. Farlow, Alexis OlsonOct 15 '16 at 2:41

• It's $n$ not $n!$ in the formula. – lulu Oct 14 '16 at 11:33
• 2,567 decimal digits is still only 2/3 a page, really. – Dan Uznanski Oct 14 '16 at 11:39
• I'm going to hazard a guess and it really means $n=1000$, it's just that the writer of the question forgot what they were doing and put that $!$ in there unintentionally. – Dan Uznanski Oct 14 '16 at 11:49
• ElementaryNumberTheory 7ed (David M.Burton) problem6.3.3 is that Question!! – 文奭允 Oct 15 '16 at 0:00

It’s $n$ in the numerator, not $n!$. It turns out that only the first four terms of the sum are non-zero:
\begin{align*} \sum_{k\ge 1}\left\lfloor\frac{1000}{5^k}\right\rfloor&=\left\lfloor\frac{1000}5\right\rfloor+\left\lfloor\frac{1000}{25}\right\rfloor+\left\lfloor\frac{1000}{125}\right\rfloor+\left\lfloor\frac{1000}{625}\right\rfloor+\left\lfloor\frac{1000}{3125}\right\rfloor+\ldots\\ &=200+40+8+1+0+0+0+\ldots\\ &=249\;. \end{align*}
Note that $p$is a prime number. look this example : $$6!=6.5.4.3.2.1=2^{1+2+1}.3^{1+1}.5^1\\=2^4.5^1.3^2=\color{red} {10^1}.2^3.3^3\\ \to 10 ^1|6!\\10!=10.9.8.7.6.5.4.3.2.1=5^2.2^8k=\color{red} {(5.2)^2}.2^6k\\ \to 10^2|10!$$ $$n!=2^k.5^m.q\\m<k\\ \to n!=(2.5)^m.\color{red} {2^{k-m}}.5^0.q \\ \to 10^m|n!$$ now it suffice to find power of 5 ,because power of 2 more than power of 5
1000!=2^k.5^m.q \\\color{red} {m<k}\\ m=\\ \begin{align*} \sum_{i\ge 1}\left\lfloor\frac{1000}{5^i}\right\rfloor&= \\&\left\lfloor\frac{1000}5\right\rfloor+\left\lfloor\frac{1000}{5^2}\right\rfloor+\left\lfloor\frac{1000}{5^3}\right\rfloor+\left\lfloor\frac{1000}{5^4}\right\rfloor+\left\lfloor\frac{1000}{5^5}\right\rfloor+\ldots\\ &=200+40+8+1+0+0+0+\ldots\\ . \end{align*}