Show that for each positive integer $n$,$$n!=\prod_{i=1}^n \; \text{lcm} \; \left\{1, 2, \ldots, \left\lfloor\frac{n}{i} \right\rfloor\right\}$$
I found a solution of this problem in this site which goes like this: "First, let's notice that the power of $p$ dividing $n!$ is $$ \sum_{i=1}^\infty \left\lfloor \dfrac n{p^i} \right\rfloor \tag{1} $$
Secondly, notice that the power of $p$ dividing $\operatorname{lcm}(1,2,...,\ell)$ is the number $q$ which satisfies $p^q \leqslant \ell \lt p^{q+1}$. So the power of $p$ dividing $\operatorname{lcm}(1,2,...,\lfloor n/k \rfloor)$ is the number $q$ which satisfies the chain of inequalities $p^q \leqslant \lfloor n/k \rfloor \lt p^{q+1}$. This latter chain of inequalities can be rewritten as $$ \dfrac{n}{p^{q+1}} \lt k \leqslant \dfrac{n}{p^q} . $$ For any given $q$, the number of all $k \in (1,2,\ldots,n)$ that satisfy this chain of inequalities is $\left\lfloor\dfrac{n}{p^q}\right\rfloor - \left\lfloor\dfrac{n}{p^{q+1}}\right\rfloor$.
So the total power of $p$ dividing $\prod\limits_{k=1}^{n} \operatorname{lcm}(1,2,\ldots,\left\lfloor n/k \right\rfloor)$ is $$ \sum_{q} q\left (\left\lfloor\dfrac{n}{p^q}\right\rfloor - \left\lfloor\dfrac{n}{p^{q+1}}\right\rfloor \right)= \sum_{q} \left\lfloor\dfrac{n}{p^q}\right\rfloor $$ Thus we could find it the same as $(1)$. And it finished our proof."
$$\textbf{My Doubt:}$$I'm not able to understand how the total power of $p$ dividing $\prod\limits_{k=1}^{n} \operatorname{lcm}(1,2,\ldots,\left\lfloor n/k \right\rfloor)$ is $$\sum_{q} q\left (\left\lfloor\dfrac{n}{p^q}\right\rfloor - \left\lfloor\dfrac{n}{p^{q+1}}\right\rfloor \right)= \sum_{q} \left\lfloor\dfrac{n}{p^q}\right\rfloor $$ The highest power of $p$ in $\operatorname{lcm}(1,2,...,\lfloor n/k \rfloor)$ is $q$ right? Then the highest power of of $p$ in $\prod\limits_{k=1}^{n} \operatorname{lcm}(1,2,\ldots,\left\lfloor n/k \right\rfloor)$ should be sum of all such $q$ we get from each $\operatorname{lcm}(1,2,...,\lfloor n/k \rfloor)$ right? How's that equal to $$\sum_{q} q\left (\left\lfloor\dfrac{n}{p^q}\right\rfloor - \left\lfloor\dfrac{n}{p^{q+1}}\right\rfloor \right)= \sum_{q} \left\lfloor\dfrac{n}{p^q}\right\rfloor$$
Note that the chain of inequalities $\dfrac{n}{p^{q+1}} < k \leq \dfrac{n}{p^q}$ gives you a continuous range of $k$'s that satisfy it for a fixed $q$, namely $\left\{\left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor + 1, \ldots, \left\lfloor \dfrac{n}{p^q} \right\rfloor \right\}$.
The number of such $k$ is then $\left\lfloor \dfrac{n}{p^q} \right\rfloor - \left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor$, and each of them contributes exactly $q$ to the total power of $p$ in $\prod_\limits{k=1}^n \operatorname{lcm}(1, 2, \ldots, \lfloor n/k \rfloor)$, thus the total power of $p$ can be written as $$\sum_q q \left( \left\lfloor \dfrac{n}{p^q} \right\rfloor - \left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor \right).$$
To simplify this sum to the desired Legendre's formula, we can see that $$\begin{aligned} \sum_q q \left( \left\lfloor \dfrac{n}{p^q} \right\rfloor - \left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor \right) &= \sum_q q \left\lfloor \dfrac{n}{p^q} \right\rfloor - \sum_q q \left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor \\ &= \sum_q q \left\lfloor \dfrac{n}{p^q} \right\rfloor - \sum_q (q-1) \left\lfloor \dfrac{n}{p^q} \right\rfloor \\ &= \sum_q \left\lfloor \dfrac{n}{p^q} \right\rfloor. \end{aligned}$$
Intuitively, note that $\left\lfloor \dfrac{n}{p^q} \right\rfloor$ counts the number of integers in $\{1, 2, \ldots, n\}$, which are divisible by $p^q$, ie. the largest power of $p$ that divides them is at least $q$. This means that $\left\lfloor \dfrac{n}{p^q} \right\rfloor - \left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor$ counts precisely the number of integers in $\{1, 2, \ldots, n\}$, which are divisible by $p^q$, but not by $p^{q+1}$, ie. the largest power of $p$ that divides them is exactly $q$. But note that $\sum\limits_q q \left( \left\lfloor \dfrac{n}{p^q} \right\rfloor - \left\lfloor \dfrac{n}{p^{q+1}} \right\rfloor \right)$ then simply sums the total power of $p$ dividing $n!$, which is precisely what Legendre's formula counts, so the two must give the same sum.