# How to count Terminal Zeros from subtraction

How do you count the number of zeros that the subtraction 100$^{100}$ - 100! ends in? In particular, I want to know exactly why my approach is wrong, because I know from my source that the answer is 24, but I do not know why. Here are my steps to solving:

First I find the number of 5's in 100!; 100/5 = 20/5 = 4, so there are 24 5's in 100! and thus 24 10's, leading to 24 terminating zeros in 100!.

Then I make 100$^{100}$ into 10$^{200}$ by (10$^{2}$)$^{100}$. So there are 200 terminating zeros in 10$^{200}$.

Now for my attempt to solve. I really just interpreted the solution as subtracting the number of terminating zeros, but with experimenting small values of powers of tens, that approach was flawed. So, in truth, I really do not know how to get 24 terminating zeros from 100$^{100}$ - 100!. Any help will be appreciated, as I have tried understanding the theory behind the problem; I just do not know how to proceed after my steps to lead me to the correct solution.

If $0< n<100^{100}$ ($n=100!$ has this property), then $n$ and $100^{100}-n$ have the same number of terminating zeros.
In fact, if $n$ has $d$ terminating zeros then $n=m10^d$ where $0< m<10^{100-d}$ and $$100^{100}-n=100^{100}-m10^d=10^d(100^{100-d}-m)$$ which has $d$ terminating because $100^{100-d}-m>0$.
• Oh, so since 100! has 10$^{24}$ as its max power of 10, but 100$^{100}$ can have more, such as 10$^{25}$, then 100! < 100$^{100}$, and therefore the terminating zeros are those of 100!? In this case being 24. How do you know that n and 100$^{100}$ - n will have the same terminating zeros, though? – Ivan Ortiz Jul 1 '17 at 8:50