How many $0$s does the number $30!$ have?

6k Views Asked by At

I want to find out the number of $0$s in the number $30!$, what should I do? Is there any trick that would work for a general question of this type, like number of $0$s in $50!$ ?

4

There are 4 best solutions below

0
On BEST ANSWER

You can use a program to see that $30!=265252859812191058636308480000000$. There are seven zeros in the end, and two in the middle. By sheer computation, this is nine zeros in $30!$. $50!=30414093201713378043612608166064768844377641568960512000000000000$, and we can count nineteen zeros in $50!$.

We can find a general formula as follows. First count the number of trailing zeros in $n!$. Since there are more factors of $2$ than factors of $5$ in $n!$, this means that there are: $$ \sum^\infty_{i=1}\left\lfloor{n\over5^i}\right\rfloor $$ zeros in the end of the number. Now, there are $\mathrm{log}(n!)$ digits in $n!$. In remaining digits (those which are not trailing zeros), each digit has $1/10$th of a chance of being a $0$, so we see that the number of zeros in $n!$ is approximated by: $$ \sum^\infty_{i=1}\left\lfloor{n\over5^i}\right\rfloor-\frac{1}{10}\left(\mathrm{log}(n!)-\sum^\infty_{i=1}\left\lfloor{n\over5^i}\right\rfloor\right) $$ Using Stirling's approximation, this gives about: $$\frac{9}{10}\sum_{i=1}^{\infty}\left\lfloor{\frac{n}{5^{i}}}\right\rfloor+\frac{1}{10}n\log_{10}n-\frac{n}{10\ln 10}+O(\ln n)$$ zeros in $n!$.

I don't think there's an closed form for this, but this gives a good approximation.

4
On

Hint: count the number of factors 2 and 5 which occurs in the numbers from 1 to 30.

2
On

For trailing zeroes its easy. A number will end in 0 if it is a multiple of 2 and 5.

The multiples of 5 between 0 and 30 are: $5, 10, 15, 20, 25, 30$ so you should expect there to be $7$ zeroes at the end of $30!$. (Notice $25 = 5^2$)

For the interior zeroes there's not short cut. You have to multiply out to discover both of them.

Also, $30! = 265252859812191058636308480000000$

10
On

The number $n!$ has $$\sum_{k\ge 1} \left\lfloor{n\over5^k}\right\rfloor$$ zeros at the end of the expanson