Number of trailing zeroes in a factorial (n!)

Number of trailing zeroes in n!
= Number of times n! is divisible by 10
= Highest power of 10 which divides n!
= Highest power of 5 in n!The question can be put in any of the above ways but it can be answered using the simple formula given below:
[n/5] + [n/25] + [n/125] +......
{ [x] is the greatest integer function. [4.99] = 4, [4.01] = 4, [ 4.99] = 5, [4.01] = 5}
The above formula gives us the exact number of 5s in n! because it will take care of all multiples of 5 which are less than n. Not only that it will take care of all multiples of 25, 125, etc. (higher powers of 5).
Note : Instead of dividing by 25, 125, etc. (higher powers of 5); it would be much faster if you divided by 5 recursively.
Let us use this to solve a few examples:
Q1) What is the number of trailing zeroes in 23! ?
[23/5 ] = 4. It is less than 5, so we stop here.
The answer is 4.Q2) What is the number of trailing zeroes in 123! ?
[123/5] = 24
Now we can either divided 123 by 25 or the result in the above step i.e. 24 by 5.
[24/5 ]= 4. It is less than 5, so we stop here.
The answer is = 24 + 4 = 28Q3): What is the number of trailing zeroes in 1123!?
[1123/5] = 224
[224/5] = 44
[44/5] = 8
[8/5] = 1.
It is less than 5, so we stop here.
The answer is = 224 + 44 + 8 + 1 =277