Hands-on argument for base p version of Legendre's formula

138 Views Asked by At

A formula that I never memorized by heart is $v_p(n!) = \frac{n-s}{p-1}$ where $s$ is the sum of the digits of $n$ in base $p$.

While it follows in a few lines from Legendre's formula, the reason I didn't memorize the above is that I do not yet grasp it intuitively. Is there a "hands-on" argument from which one "immediately" sees that this fraction has to be the correct term (other than the straightforward computation from Legendre's formula)?

2

There are 2 best solutions below

2
On BEST ANSWER

As Daniel Fischer's question comment outlines, consider the sum of digits in base $b$ of $i - 1$ compared to $i$. The smallest power (i.e., right-most) non-zero digit of $i$ is decreased by $1$ and all of the $0$ terms, if any, to the right of it are changed to $b - 1$. For example, in base $10$, you get $2100 - 1 = 2099$. Since the number of $0$ terms to the right of the lowest power non-zero one is $\nu_{b}(i)$, this means there's a net change in the digits sum of $-1 + (b - 1)\nu_{b}(i)$. Having $s_p(j)$ be the sum of digits of $j$ in base $p$, this gives for any $i \gt 0$ that

$$\begin{equation}\begin{aligned} s_p(i - 1) & = s_p(i) - 1 + (p - 1)\nu_{p}(i) \\ (p - 1)\nu_{p}(i) & = - s_p(i) + s_p(i - 1) + 1 \\ \nu_{p}(i) & = \frac{- s_p(i) + s_p(i - 1) + 1}{p - 1} \\ \nu_{p}(i) & = \frac{i - s_p(i) + s_p(i - 1) + 1 - i}{p - 1} \\ \nu_{p}(i) & = \frac{(i - s_p(i)) - ((i - 1) - s_p(i - 1))}{p - 1} \\ \end{aligned}\end{equation}\tag{1}\label{eq1B}$$

Since

$$\nu_p(n!) = \sum_{i = 1}^{n}\nu_p(i) \tag{2}\label{eq2B}$$

then \eqref{eq1B} shows \eqref{eq2B} is summing a telescoping series. Thus, each first positive term cancels with the negative term of the next summation item, so all which is left is the positive term of the largest summation item, i.e., $n - s_p(n)$, and the negative term of the first summation item, i.e., $0$. Thus, \eqref{eq2B} becomes

$$\nu_p(n!) = \frac{n - s_p(n)}{p - 1} \tag{3}\label{eq3B}$$

2
On

With

$$\nu_p(n!) = \frac{n - s}{p - 1} \tag{1}\label{eq1A}$$

I don't know of any argument allowing you to "immediately" see this is true. Nonetheless, here's a alternate explanation which may not be more "hands-on", but it doesn't directly use the Legendre's formula proof and you may find it more intuitive.

As is done in the linked proof, define

$$n = \sum_{i=0}^{l}n_{i}p^{i} \tag{2}\label{eq2A}$$

A key element is the net contribution to $\nu_p(n!)$ from each $n_{i}p^{i}$ term in \eqref{eq2A} (as specified by $g(j)$ in \eqref{eq4A} below) is independent of all of the other terms' contributions. To see this, first $\forall \; 0 \le j \le l$ define

$$f(j) = \sum_{i=0}^{j}n_{i}p^{i} \tag{3}\label{eq3A}$$

$$g(j) = \begin{cases} \emptyset & \text{ if } j = 0, n_0 = 0 \\ [1, f(j)] & \text{ if } j = 0, n_0 \gt 0 \\ [f(j-1) + 1, f(j)] & \text{ if } j \gt 0 \end{cases} \tag{4}\label{eq4A}$$

For $j \gt 0$, the # of factors of $p$ in the product of the elements of $g(j)$ is given by

$$\begin{equation}\begin{aligned} \nu_p\left(\prod_{i=f(j-1)+1}^{f(j)}i\right) & = \sum_{i=f(j-1)+1}^{f(j)}\nu_p(i) \\ & = \sum_{i=1}^{n_jp^j}\nu_p(i) + \sum_{i=n_jp^j + 1}^{f(j)}\nu_p(i) - \sum_{i=1}^{f(j-1)}\nu_p(i) \\ & = \sum_{i=1}^{n_jp^j}\nu_p(i) + \sum_{i=1}^{f(j-1)}\nu_p(n_jp^j + i) - \sum_{i=1}^{f(j-1)}\nu_p(i) \\ & = \sum_{i=1}^{n_jp^j}\nu_p(i) + \sum_{i=1}^{f(j-1)}\left(\nu_p(n_jp^j + i) - \nu_p(i)\right) \\ \end{aligned}\end{equation}\tag{6}\label{eq6A}$$

Note $\nu_p(m)$ is equal to the power of the right-most (i.e., smallest power) non-zero term in the base $p$ expansion of $m$. Since $\forall \; 1 \le i \le f(j-1)$ the right-most non-zero term in the base $p$ expansion of $n_jp^j + i$ and $i$ are the same, you get $\nu_p(n_jp^j + i) - \nu_p(i) = 0$. Thus, the second summation in \eqref{eq6A} is $0$, which means

$$\nu_p\left(\prod_{i=f(j-1)+1}^{f(j)}i\right) = \sum_{i=1}^{n_jp^j}\nu_p(i) \tag{7}\label{eq7A}$$

Among the integers from $1$ to $n_jp^{j}$, there are $n_jp^{j-1}$ with at least one factor of $p$. Among these, there are $n_jp^{j-2}$ integers with at least two factors of $p$. Continue this until you get to there being $n_j$ integers with $j$ factors of $p$. Adding these together gives

$$\begin{equation}\begin{aligned} \sum_{i=1}^{n_jp^j}\nu_p(i) & = \sum_{i=0}^{j-1}n_jp^{i} \\ & = n_j\left(\frac{p^{j} - 1}{p - 1}\right) \\ & = \frac{n_jp^{j} - n_j}{p - 1} \end{aligned}\end{equation}\tag{8}\label{eq8A}$$

With $j = 0$, \eqref{eq8A} gives $0$ so it also applies for $g(0)$. Since each set of $g(j)$ in \eqref{eq4A} is disjoint, and the union of them is all the integers up to $n$, then summing \eqref{eq8A} for $0 \le j \le l$ gives the number of factors of $p$ in the product of all integers up to $n$, i.e., $\nu_p(n!)$. Thus,

$$\begin{equation}\begin{aligned} \nu_p(n!) & = \sum_{j=0}^{l}\left(\frac{n_jp^{j} - n_j}{p - 1}\right) \\ & = \frac{\sum_{j=0}^{l}n_jp^{j} - \sum_{j=0}^{l}n_j}{p - 1} \\ & = \frac{n - s}{p - 1} \end{aligned}\end{equation}\tag{9}\label{eq9A}$$