When we consider factorial, number of 2's will always be greater than number of 5's. So, we just need to count the no. of powers of 5.
In n! , we have factors that are multiples of 25,125….. If we divide them by , we get , still multiples of 5. This means that we still have that needs an even pair, so we need to divide again by .
Now, since we have already counted the 5’s in the first division, we need to count the second set of 5’s. Instead of dividing again by , we divide them by and next by 125 and so on. That is the reason why we also divide n by powers of 5.
Count of 5s in n! = floor(n/5) + floor(n/25) + floor(n/125) + .…
= $\frac{50}{5}$ +$\frac{50}{25}$ + $\frac{50}{125}$
= 10 + 2 + 0
= 12