# Number of zeros in factorial of a number

1. Aug 12, 2010

1. The problem statement, all variables and given/known data

This is not a homework problem. I was just wondering the logic and intuition behind the "formula" for finding the number of zeros given the factorial of a number.

2. Relevant equations

Formula : round(n/5) + round(n/25) + round(n/125)+.......+round(n/5^n)
Here, round function indicates that only the integer part of (n/5^n) should be taken.

Example1 : Say if you want to find the number of zero's in 5! ??

Usage : In this case n = 5.

-> round(5/5) + round(5/25)+....

->round(1) + round(0)

-> 1 (1 zero in 5!)

Example2 : find the number of zero's in 130! ??

Usage : In this case n = 130.

-> round(130/5) + round(130/25) + round(130/125) ....

->round(26) + round(5) + round(1)

-> 32 (32 zeroes in 130!)

Thanks!!

2. Aug 12, 2010

### Char. Limit

That round function looks like the "nearest integer function" [x], which returns the nearest integer less than or equal to x.

So your function looks like this?

$$\sum_{n=1}^\infty \left[\frac{x}{5^n}\right]$$

I would assume it has to do with the fact that the factorial, being the product of integers, requires a factor of 10=5*2 for one zero, a factor of 100=10*5*2 for two zeros, etc.

3. Aug 12, 2010

### thrill3rnit3

It's because 5 and 2 make 10, which has one 0. There will be more 2s than 5s, so you only need to find how many 5s there are to match up with the 2s.

Now let's look at the formula itself. Normally to find how many fives there are, you divide by 5. Say 26/5 = 5 fives.

However, 25 in itself has 2 5's (5*5), so if you don't divide by 25, you will miss the other 5. Same goes when x > 125, x > 625, etc. 125 = 5^3, and 625 = 5^4, so you need to divide by those numbers in order to take all 5s into account.

Ask more questions if my explanation isn't clear enough.