How many 0's are at the end of 20!

There is a general formula that can be used. But it is good to get one's hands dirty and compute.

If $20!$ seems dauntingly large, calculate $10!$. You will note it ends with two zeros. Multiplying $10!$ by all the numbers from $11$ to $20$ except $15$ and $20$ will not add to the zeros. Multiplying by $15$ and $20$ will add one zero each.

Remark: Suppose that we want to find the number of terminal zeros in something seriously large, like $2048!$. It is not hard to see that this number is $N$, where $5^N$ is the largest power of $5$ that divides $2048!$. This is because we need a $5$ and a $2$ for every terminal $0$, and the $5$s are the scarcer resource.

To find $N$, it is helpful to think in terms of money. Every number $n$ between $1$ and $2048$ has to pay a $1$ dollar tax for every $5$ "in it." So $45$ has to pay $1$ dollar, but $75$ has to pay $2$ dollars, because $75=5^2\cdot 3$. And a $5$-rich person like $1250$ has to pay $4$ dollars.

Let us gather the tax in stages. First, everybody divisible by $5$ pays a dollar. These are $5$, $10$, $15$ and so on up to $2045$, that is, $5\cdot 1, 5\cdot 2,\dots, 5\cdot 409$. So there are $409$ of them. It is useful to bring in the "floor" or "greatest integer $\le x$ " function, and call the number of dollars gathered in the first stage $\lfloor 2048/5\rfloor$.

But many numbers still owe some tax, namely $25,50,75,\dots,2025$. Get them to pay $1$ dollar each. These are the multiples of $25$, and there are $\lfloor 2048/25\rfloor$ of them.

But $125$, $250$, and so on still owe money. Get them to pay $1$ dollar each. We will gather $\lfloor 2048/125\rfloor$ dollars.

But $625$, $1250$, and $1875$ still owe money. Gather $1$ dollar from each, and we will get $\lfloor 2048/625\rfloor$ dollars.

Now everybody has paid up, and we have gathered a total of $$\lfloor 2048/5\rfloor + \lfloor 2048/25\rfloor +\lfloor 2048/125\rfloor +\lfloor 2048/625\rfloor$$ dollars. That's the number of terminal zeros in $2048!$.


Count up the number of factors of $5$ and the number of factors of $2$ in $20!$. Since we get a zero for every pair of factors $5\cdot 2$, then the minimum of these will answer your question. More simply, $5$ happens less often as a factor (since it's bigger than $2$), so we need only count up the number of $5$'s. In particular, there's one each in $5,10,15,20$, so there are $4$ zeroes at the end.

If the problem had asked about $25!$, then there'd be $6$ zeroes--not $5$--because there are two factors of $5$ in $25$. Similar idea for other numbers.