Q: Given an integer n, how many 0 are there at the end of the factorial n! of n? For example: N = 10,n! = 3628800, n! at the end of the two X 0
Analysis and Solution:
Some people encounter such problems, is not to complete the calculation of the value of n!? What if it overflows? In fact, the problem becomes simple if we take the view that "which numbers multiply to get 10".
Consider first, if n! = k * 10M, and K cannot be divisible by 10, then n! at the end of M 0. Then consider the decomposition of the n! to the mass factor, N! = (2X) * (3Y) * (5Z) ....., because 10=2*5, so M is only related to X and Z, each pair of 2 and 5 can get a 10, so M=min (X,z). It is not difficult to see that X is greater than or equal to Z, because the number that can be divisible by 2 is much higher than the number that can be divisible by 5, so the formulation is simply m=z.
Don't be intimidated by factorial.