Is there any formula to compute $\sum\limits_{i=1}^{i=k}\lfloor{\frac{n}{5^i}\rfloor}$?

48 Views Asked by At

This is the formula we use to calculate the number of trailing zeros in $n!$ but we have to add the individual elements of the sum to get up with an answer. Is there any way we can bypass that?

1

There are 1 best solutions below

0
On

Let $r=1/5$.

Without the floor function, we have

$$\sum_{i=1}^knr^i=n\frac{r-r^{k+1}}{1-r}$$

With the floor function, we have

$$\sum_{i=1}^k\left\lfloor nr^i\right\rfloor\le\left\lfloor n\frac{r-r^{k+1}}{1-r}\right\rfloor$$

We also have that for $k\ge a=\lceil\log_{1/r}(n)\rceil:$

$$\sum_{i=1}^k\left\lfloor nr^i\right\rfloor=\sum_{i=1}^a\left\lfloor nr^i\right\rfloor\le\left\lfloor n\frac{r-r^{a+1}}{1-r}\right\rfloor$$

which seems to be pretty close to the correct value.enter image description here