# Factorial Trailing zeroes intuition

I get that when we're trying to get the number of zeroes in 23!, we do 23/5 = 4 and we know there are 4 zeroes. My question is why only divide 23 by 5? What about 20, 15, 10, 5 all these numbers that are multiples of 5 and why does dividing 23 by 5 yield the number of 5's in the factorial? What's the mathematical intuition?

Dividing $23$ by $5$ tells us how many multiples of $5$ there are less than (or equal to) $23$. That is how many multiples of $5$ occur in the product: $23\times 22\times \cdots \times 1$. Thus that product has $5^4$ as a factor. It also has $2^4$ as a factor, because $2$'s come much more frequently than $5$'s as we collect factors from $1$ to $23$. Thus the factorial has $10^4$ as a factor, hence $4$ zeros.
It's not just a matter of counting the number of $5$'s though. If we look at $25!$, it ends with $6$ zeros, because when we reach $25$, we add not one but two factors of $5$, because $25$ is $5^2$.
• Well, $5$ goes into $23$ four times, so if you count by $5$'s, you go through four multiples before getting there. Jul 27, 2017 at 5:37
• @curiousBiggie it's the definition of integer division: $23$ divided by $5$ equals the number $d$ such that we can write $23 = 5d + r$ with $0 \le r < 4$. where $r$ is the remainder. Then the numbers $5k$ are all the positive multiples of $5$ below $23$ for $k=1,\ldots d$, do $d$ many. Jul 27, 2017 at 5:41
• @curiousBiggie yes because $23 = 4\times 5 + 3$ Jul 27, 2017 at 5:43