4

I (as a teacher) saw in a book for $8^{th}$ grade students that the number of trailing zeroes of ${n!}\times{m!}$ is the sum of the trailing zeroes of $n!$ and $m!$. There also has been noticed that the number of trailing zeroes of $\dfrac{n!}{m!}$ ($m<n$) is their subtraction. i.e.

$$(\left\lfloor \frac{n}{5}\right\rfloor+ \left\lfloor \frac{n}{5^2}\right\rfloor+ \left\lfloor \frac{n}{5^3}\right\rfloor+\cdots)-(\left\lfloor \frac{m}{5}\right\rfloor+ \left\lfloor \frac{m}{5^2}\right\rfloor+ \left\lfloor \frac{m}{5^3}\right\rfloor+\cdots).$$

But I think this is wrong because for example $\dfrac{15!}{14!}=15$ but $3-2=1$.

Can one prove that this statement is correct if $n>m-1$? If so why this restriction is necessary?

Of course it is obvious that $\dfrac{(n+1)!}{n!}=n+1$ and the number of trailing zeroes depend on the number of trailing zeroes of the number $n+1$.

Where does this strange behavior comes from? i.e. in product of factorials we sum number of trailing zeroes but in division we should care about it?

Note: I always make mistakes in simple math calculations. Am I wrong here?

C.F.G
  • 8,523
  • 2
    See also: https://math.stackexchange.com/q/141196/700480 . Note the accepted answer makes it clear that the number of zeros $n!$ ends with is $\left\lfloor \frac{n}{5}\right\rfloor+ \left\lfloor \frac{n}{5^2}\right\rfloor+ \left\lfloor \frac{n}{5^3}\right\rfloor+\cdots$.

    However, the number of zeros a quotient ends with may not be the difference of the number of zeros the dividend and divisor end with (cf. $15=60/4$) precisely because divisibility by $2$ "springs" into action. (The bottom line reason: $10$ is not prime.)

    –  Sep 25 '20 at 11:01

2 Answers2

8

The formula will be wrong lots of times. For example, $125!/122!$ has two trailing $0$’s, while the formula suggests $3$. The problem is that there are more $5$’s in the factorization than $2$’s.

If you calculate the corresponding formula for $2$ and take the minimum of the two values, you’ll correct the formula.

The formula that is stated counts the number of $5$'s in the factorization of the quotient $\frac{n!}{m!}$. Usually, in factorials, $5$ is scarcer than $2$. In the quotient, however, it is possible that $2$ becomes rarer. Therefore, if you take the formula that counts the number of $2$'s, you'll see that, for example, $\frac{15!}{14!}$ has $(7+3+1)-(7+3+1)=0$ factors of $2$, so it has no trailing $0$'s.

Michael Burr
  • 32,867
  • 1
    +1. Thanks a lot. // What about this condition: $m\leq n-5$? I think with this restriction the subtraction formula holds. – C.F.G Sep 25 '20 at 12:25
  • 1
    Try $n=5^5=3125$ and $m=3120$. Then $\frac{n!}{m!}$ has $3$ trailing zeros, but the formula would give you $5$. Again, this is because $\frac{n!}{m!}=2^35^5k$ where $k$ is relatively prime to $2$ and $5$. – Michael Burr Sep 25 '20 at 12:50
0

Let $\lfloor r\rfloor$ denote the floor of $r$.

For prime $p$ and positive integer $n$, let
$V_p(n)$ denote the largest exponent $\alpha$
such that $p^{\alpha} | n.$
Note that under this definition
$p^{(\alpha + 1)} \not | n.$

The formula for $V_p(n!)~$ is $~\lfloor \frac{n}{p^1}\rfloor ~+~ \lfloor \frac{n}{p^2}\rfloor ~+~ \lfloor \frac{n}{p^3}\rfloor ~+~ \lfloor \frac{n}{p^4}\rfloor ~+~ \cdots $

Using this formula, the precise formula for the # of trailing zeros that
a number will have is $\min\{V_2(n), V_5(n)\}.$

It's easy to see that in general, $V_5(n!) \leq V_2(n!).$

I recommend against any attempt to shortcut the formula.
For example, if $n > m$, there is no way to guarantee that
$V_5(n!) - V_5(m!) = m - n.$

In fact, one of the ways of showing that
$\binom{n}{k}$ is an integer,
when $~n ~\in ~\mathbb{Z^+}$ and $k \in \{0,1,\cdots, n\}$
is by showing that for any prime $p$,
$V_p(n!) \geq \{V_p(k!) + V_p([n-k]!)\}.$

Addendum
I really didn't focusing on the internals of where the OP's computation could lead to the wrong result.

Therefore, see also Michael Burr's subsequent comment to this answer.

user2661923
  • 35,619
  • 3
  • 17
  • 39
  • 1
    It may be worth mentioning that in the OP's question, even though $V_5(n!)\leq V_2(n!)$ and $V_5(m!)\leq V_2(m!)$, it is not true that $V_5(n!)-V_5(m!)\leq V_2(n!)-V_2(m!)$. This is the reason that the formula fails in the given case. – Michael Burr Sep 25 '20 at 11:20