1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Number of zeros in factorial of a number

  1. Aug 12, 2010 #1
    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!)

  2. jcsd
  3. Aug 12, 2010 #2

    Char. Limit

    User Avatar
    Gold Member

    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?

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

    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.
  4. Aug 12, 2010 #3


    User Avatar
    Gold Member

    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Number of zeros in factorial of a number
  1. Number Sequences (Replies: 2)

  2. Complex numbers (Replies: 6)