Trailing zeroes in factorials: are there any excluded values divisible by 5 other than $5$ and $30$?

209 Views Asked by At

I've discovered that when this algorithm for counting zeroes on the end of $n!$ is applied to some $n\in\Bbb{N}$: $$f(n)=\sum_{k=1}^{k:n/5^k\le1}\left\lfloor\frac{n}{5^k}\right\rfloor\notin\{5,30\}$$ Are the any other numbers $n:5|n$ that I could add to the set?

Now, a companion question would be: What are the multiples of $2$ that get skipped?

Just because a number gets skipped, doesn't mean it's divisible by $5$; I found $40!$ to $49!$ have $10$ trailing zeroes, but $50!$ has $12$, skipping $11$. $$f(n)\notin\{5,11,17,18,23,29,30,...\}$$ Am I doing something wrong, or are these numbers supposed to be skipped?

2

There are 2 best solutions below

0
On BEST ANSWER

There is an important self-similar sequence that goes:

0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2,

where I've grouped terms into bigger blocks. The "pattern" that makes this self similar is "=, =, =, =, +1" where "=" means repeat the working block unit and "+1" means to increment the block unit by adding one to the last element. In other words, you keep building large and larger block by repeating this rule. So taking the 5 lines above as a single block, we can build the larger self-similar sequence by repeating it 4 times and then having the +1 block:

0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3,

In this way, we build the self similar sequence of "exponents of 5" in the natural numbers. We can add these up, and these give the values you are looking for because every new 5 added to a factorial will already have a matching 2 (2 < 5 so occurs more often) and we get a new trailing zero.

Now you can already see in this sequence that you will have an infinite number of places where you skip a sum that is divisible by 5. Most of the time you are adding only one and when you add more, you might skip a multiple. This will "roll" around on the sum, where sometimes you sum a one onto a multiple of five and do this for a few runs until you line back up to skip the multiple of five. This argument can be made rigorous using the fact that you can prove it at block level 2 that a multiple is skipped at that level and then induct to each higher level of self-similarity. Once you show that block level 2 will always skip at all starting integers (mod 5) then you are done, as you know the gap will never be larger than 30 (though may be less due to wrap around from higher block levels).

The numbers under 1000 that are multiples of 5 and skipped are:

5 30 60 85 110 135 155 185 210 235 260 285 310 335 360 385 410 435 465 485 510 535 560 590 615 635 660 685 715 740 765 780 810 835 860 885 910 935 960 985

Note that these kinds of self-similar sequences are very useful if you are interested in divisibility results for other exponents besides 5. They have the same type of pattern, in the obvious way.

0
On

For $k \geqslant 2$, we have

$$f(5^k) = \frac{5^k-1}{5-1} \equiv 1 \pmod{5},$$

so the multiple

$$\frac{5^{k-1}-1}{4}\cdot 5$$

of $5$ is skipped. That produces the sequence $5,5+5^2 = 30, 5+5^2+5^3 = 155, 155+5^4 = 780,\dotsc$ of skipped multiples of $5$.

There are more, for example $f(350) = 70+14+2 = 86$, so $85$ is skipped. Generally, if we call $s_5(n)$ the sum of the digits in the base-$5$ representation of $n$, then we have

$$f(n) = \frac{n-s_5(n)}{4}.$$

$f(n)$ skips $k-1$ values when $n$ is a multiple of $5^k$ but not of $5^{k+1}$, and among the skipped values is a multiple of $5$ whenever $k-1 \geqslant 5$, or the remainder of $f(n)$ modulo $5$ is between $1$ and $k-1$ (inclusive). The latter condition translates to $1 \leqslant s_5(n) \bmod{5} \leqslant k-1$ for $2 \leqslant k \leqslant 5$, and I used that to find the example $350 = 2\cdot 5^3 + 4\cdot 5^2$ as the smallest number that is not a power of $5$ and leads to a skipped multiple of $5$ in the $f(n)$ sequence.