-1

Usually, it is done like this: If $[t]$ denotes the greatest integer less than or equal to $t$, then

$$ \text{the exponent of $p$ in $n!$} = \bigg[\frac{n}{p}\bigg] + \bigg[\frac{n}{p^2}\bigg] + \bigg[\frac{n}{p^3}\bigg] + \cdots $$

and it does give the answer, but, it is totally non-intuitive and i can't use it comfortably enough!

Sangchul Lee
  • 167,468
e_t
  • 19
  • Welcome to MSE! I edited your question to a more readable form. Please take a moment to give a read on How to ask a good question. – Sangchul Lee Jun 07 '18 at 04:33
  • 1
    MathJax hint: rather than square brackets for the floor function we use \lfloor and \rfloor. You can prefix them with \left and \right as well. – Ross Millikan Jun 07 '18 at 04:33
  • Why isnt your answer intuitive enough? Imagine lining up all the integers from 1 to n. Every p elements are divisible by p at least once. Count them. Every p$^{2}$ elements are divisible by p at least once more. Count them. Etc... – David Diaz Jun 07 '18 at 14:40
  • I wrote a proof using induction years ago, http://math.stackexchange.com/questions/141196/highest-power-of-a-prime-p-dividing-n/228351#228351 – Will Jagy Jun 07 '18 at 17:08
  • David Diaz...... .So basically, the floor function literally "counts" the factors??? – e_t Jun 08 '18 at 17:15

2 Answers2

3

The $\left\lfloor \frac np \right\rfloor$ counts one factor of $p$ from every multiple of $p$. The $\left\lfloor \frac n{p^2} \right\rfloor$ counts one additional factor of $p$ from every multiple of $p^2$ and so on. As an example, take $p=5, n=679$. There are $\left\lfloor \frac {679}5 \right\rfloor=135$ multiples of $5$, starting with $5$ and ending with $675=5\cdot 135$. The multiples of $25$ have another factor of $5$ and there are $\left\lfloor \frac {679}{25} \right\rfloor=27$ of them. The multiples of $5^3=125$ have another factor of $5$ and the one multiple of $5^4=625$ has yet one more.

Ross Millikan
  • 374,822
1

It is easily understood in terms of double counting: if $\operatorname{ord}_p m$ denotes the exponent of the factor $p$ in $m$ and

$$ \mathbf{1}_{\{\cdots\}} = \begin{cases} 1, & \text{if $\cdots$ is true} \\ 0, & \text{if $\cdots$ is false} \end{cases} $$

denotes the indicator function for the statement $\cdots$, then

$$ \operatorname{ord}_p (n!) = \sum_{k=1}^{n} \operatorname{ord}_p k = \sum_{k=1}^{n} \sum_{l=1}^{\infty} \mathbf{1}_{\{p^l \mid k\}} = \sum_{l=1}^{\infty} \sum_{k=1}^{n} \mathbf{1}_{\{p^l \mid k\}} = \sum_{l=1}^{\infty} \bigg\lfloor \frac{n}{p^l} \bigg\rfloor. \tag{1}$$

The following figure demonstrates the case $n = 65$ with $p=2$.

$\hspace{4em}$figure 1: bins

Here, the presence of a black bead at $(k, l)$ means that $p^l$ divides $k$. So

  • The number of beads at $k$ represents the highest power of $p$ that divides $k$, hence is $\operatorname{ord}_p k$.

  • The number of beads at height $l$ represents the total number of integers $\leq n$ which are divisible by $p^l$, i.e., the number of multiples of $p^l$ in $\{1, \cdots, n\}$. This is exactly $\lfloor n/p^l \rfloor$.

Then the LHS of $\text{(1)}$ counts the total number of beans from left to right, while the RHS of $\text{(1)}$ counts the total number of beans from bottom to top.

Sangchul Lee
  • 167,468