2

Theorem: Given an integer $n$ and prime number $p$, let $S(n)$ be the sum of digits of $n$ in base $p$ and let $v(n)$ be the highest power of $p$ in $n!$. Then,

$v(n) = \frac{n-S(n)}{p-1}$


I found this theorem when I was learning about the number of trailing zeroes in a factorial, here. Is there a formal proof to this theorem? I cannot digest it. Explain?

N Nair
  • 123

1 Answers1

2

Let us adopt the notation $m_p(x)$ to denote the largest natural so that $p^{m_p(x)}$ divides a natural $x$; that is, $m_p(x)$ is the multiplicity of $p$ in $x$.

Clearly, $m_p(n!) = \sum_{i = 1}^n m_p(i)$. Now, there is a way to "transpose" this sum by indexing over the possible values of $m_p$; observing that $\lfloor n / p^\alpha \rfloor$ counts the number of distinct indices $i $ with $m_p(i) \ge \alpha$, we have $$m_p(n!) = \sum_{\alpha = 1}^{\infty} \lfloor n / p^\alpha \rfloor$$ This simple derivation is called Legendre's formula.

Your own proposition is not very far away; it is enough to see a relationship between the terms of our sum and the coefficients of your base-$p$ expansion of $n$, $\beta_0 + \beta_1 p + \dots \beta_k p^k$. When $\alpha \le k$, we have $$\lfloor n / p^\alpha \rfloor = \sum_{i = \alpha}^k \beta_i p^{i - \alpha} $$ Notice that $m_p$ does not take value higher than $k$ in the range $ \{ 1 \dots n \}$. It follows that $m_p(n!)$ can be written as the nested sum $$\sum_{\alpha = 1}^{k} \sum_{i = \alpha}^k \beta_i p^{\alpha - i}$$ This sum can be reindexed, yielding: $$\sum_{i = 1}^k \sum_{\alpha = 0}^{i - 1} \beta_i p^\alpha = \sum_{i = 1}^k \frac{\beta_i(p^i - 1)}{p - 1}$$ This last expression is just $(n - \sum b_i) / (p - 1)$.