If $2^a$ is the highest power of 2 which divides $n!$, show that $a$ lies between $n-1$ and $n-\lfloor \log_2(n+1)\rfloor$.
It is assumed that $n \in \Bbb{Z^+}.$
This answer is a response to the OP's (i.e. original poster's) comment-question, which follows his original posting.
This answer is nothing more than a regurgitation of the following (already posted comments):
- user2661923 (me) : See Legendre's formula.
- Thomas Andrews : Try strong induction.
$a(n) = \lfloor n/2\rfloor + a( ~\lfloor n/2\rfloor ~)$.
Adopting the syntax of the linked Wikipedia article, you have that :
$$v_2(n!) = \sum_{i=1}^\infty \left\lfloor \frac{n}{2^i} \right\rfloor. \tag1 $$
Then, the OP's assertion translates to
To Prove: $(n-1) \geq v_2(n!) \geq n - \lfloor \log_2(n+1) \rfloor.$
The two (bullet pointed) comments above may be used to construct $2$ distinct solutions. I will present both solutions below.
$\underline{\text{Solution 1}}$
In my opinion, the induction approach indicated by the comment of Thomas Andrews provides an elegant solution. Therefore, I will present this solution first.
Let $b = \lfloor n/2\rfloor.$
This solution will need some intermediate results.
The first intermediate result is the one indicated by his comment:
$$\text{To Prove}: ~~v_2(n!) = b + v_2(b!). \tag{IR-1}$$
Proof:
$b = \lfloor (n/2) \rfloor \implies $
$\lfloor b/2 \rfloor = \lfloor (n/4) \rfloor \implies$
$\lfloor b/4 \rfloor = \lfloor (n/8) \rfloor \implies$
$\lfloor b/8 \rfloor = \lfloor (n/16) \rfloor \implies$
$\cdots$
Therefore, using (1) above
$v_2(n!) = \sum_{i=1}^\infty \left\lfloor \frac{n}{2^i} \right\rfloor = b + \sum_{i=2}^\infty \left\lfloor \frac{n}{2^i} \right\rfloor = b + \sum_{i=1}^\infty \left\lfloor \frac{b}{2^i} \right\rfloor = b + v_2(b!).$
This completes the proof of (IR-1) above.
Second intermediate result:
$$\text{To Prove}: ~~n = 2b ~~\text{or} ~~n = 2b + 1. \tag{IR-2}$$
Proof:
$b = \lfloor n/2 \rfloor \implies b \leq n/2 < b + 1 \implies 2b \leq n < 2b+2.$
This completes the proof of (IR-2) above.
Third intermediate result:
$$\text{To Prove}: ~~2b - \lfloor \log_2(b+1) \rfloor \geq n - \lfloor \log_2(n+1) \rfloor. \tag{IR-3}$$
Proof:
IR-3 is immediate for $n=1$. Assume $n > 1$.
Assume that $2^r \leq n < 2^{(r+1)} ~: ~r \in \Bbb{Z^+}.$
IR-3 will be proven by considering the $(3)$ possibilities of
$n = 2^{(r+1)}-1, ~~n = 2^{(r+1)} - 2,~~$ and $~~n < 2^{(r + 1)} - 2~~$ separately.
$n = 2^{(r+1)} - 1 \implies$
- $\lfloor \log_2(n+1) \rfloor = r + 1$.
- $b = 2^r - 1 \implies n = 2b + 1$.
- $\lfloor \log_2(b+1) \rfloor = r$.
$\implies$
$2b - \lfloor \log_2(b+1) \rfloor = (2b - r) = [(2b+1) - (r + 1)] = n - \lfloor \log_2(n+1) \rfloor.$
$n = 2^{(r+1)} - 2 \implies$
- $\lfloor \log_2(n+1) \rfloor = r$.
- $b = 2^r - 1 \implies n = 2b$.
- $\lfloor \log_2(b+1) \rfloor = r$.
$\implies$
$2b - \lfloor \log_2(b+1) \rfloor = (2b - r) = (n - r) = n - \lfloor \log_2(n+1) \rfloor.$
Assuming that $r \geq 2$:
$2^r \leq n < 2^{(r + 1)} - 2 \implies $
- $\lfloor \log_2(n+1) \rfloor = r$.
- $2^{(r-1)} \leq b < 2^r - 1$.
- $\lfloor \log_2(b+1) \rfloor = r-1$.
- Using (IR-2): $2b+1 \geq n.$
$\implies$
$2b - \lfloor \log_2(b+1) \rfloor = 2b - (r-1) = (2b+1) - r \geq n - r = n - \lfloor \log_2(n+1) \rfloor.$
This completes the proof of (IR-3) above.
The remainder of this solution will use (strong) induction to prove the OP's assertion, via the intermediate results.
Induction - base case: $~n = 1$.
$v_2(1!) = 0~~$ and $~~(1-1) \geq 0 \geq 1 - \lfloor\log_2(1 + 1)\rfloor.$
Induction - strong induction assumption:
Suppose that the assertion holds for each element in $\{1,2,3,\cdots, 2^r - 1\} ~: ~r \in \Bbb{Z^+}.$
Let $n$ be any element in $\{2^r, 2^r + 1, 2^r + 2, \cdots, 2^{(r+1)} - 1 \}.$
This implies that $b < 2^r$.
By the (strong) inductive assumption
$b - 1 \geq v_2(b!) \geq b - \lfloor\log_2(b+1)\rfloor \implies $
$2b - 1 \geq b + v_2(b!) \geq 2b - \lfloor\log_2(b+1)\rfloor \implies $
[Using IR-1]
$2b - 1 \geq v_2(n!) \geq 2b - \lfloor\log_2(b+1)\rfloor \implies $
[Using IR-2 and IR-3]
$n - 1 \geq v_2(n!) \geq n - \lfloor\log_2(n+1)\rfloor.$
Thus:
- The OP's assertion is true for $n=1$.
- If the OP's assertion is true for all $n < 2^r ~: r \in \Bbb{Z^+}$,
then the assertion is also true for all $n$ such that
$2^r \leq n < 2^{(r+1)}.$
Therefore, the OP's assertion is true for all $n$.
$\underline{\text{Solution 2}}$
This solution is less elegant than the first solution.
Examining (1) above and the corresponding Wikipedia article, it is clear that although the summation goes from $1$ to $\infty$, there are only a finite number of non-zero terms.
Therefore, you have the strict inequality that:
$$v_2(n!) < \sum_{i=1}^\infty \frac{n}{2^i}. \tag2 $$
However, since
$\displaystyle \sum_{i=1}^\infty \frac{1}{2^i} = 1$,
(2) above implies that $n > v_2(n!) \implies (n-1) \geq v_2(n!)$,
since $v_2(n!)$ has to be an integer.
For the other part of the inequality in the OP's assertion:
$n=1 \implies v_2(n!) = 0 = 1 - \lfloor \log_2(1+1)\rfloor.$
Therefore, without loss of generality, $n \geq 2.$
Assume that $2^r \leq n < 2^{(r+1)} ~: ~r \in \Bbb{Z^+}.$
The $(2)$ possibilities of
$n = 2^{(r+1)} - 1 ~~$ or $~~2^r \leq n < 2^{(r+1)} - 1$ will be handled separately.
For $n = 2^{(r+1)} - 1$:
$\lfloor \log_2(n+1) \rfloor = r+1.$
$\displaystyle v_2(n!) =
\left\lfloor \frac{2^{(r+1)} - 1}{2^1} \right\rfloor
+ \left\lfloor \frac{2^{(r+1)} - 1}{2^2} \right\rfloor
+ \left\lfloor \frac{2^{(r+1)} - 1}{2^3} \right\rfloor
+ \cdots
+ \left\lfloor \frac{2^{(r+1)} - 1}{2^r} \right\rfloor $
$\displaystyle = \left[2^r - 1\right]
+ \left[2^{(r-1)} - 1\right]
+ \left[2^{(r-2)} - 1\right]
+ \cdots
+ \left[2^1 - 1\right]$
$\displaystyle = \left[2^r + 2^{(r-1)} + 2^{(r-2)}
+ \cdots + 2^1\right] - r = \left[2^{(r+1)} - 2\right] - r$
$\displaystyle = \left[2^{(r+1)} - 1\right] - (r+1)
= n - \lfloor\log_2(n+1)\rfloor.$
For $2^r \leq n < 2^{(r+1)} - 1$:
$\lfloor \log_2(n+1) \rfloor = r.$
Note that for $i \in \{1,2,\cdots,r\}$
$\displaystyle \frac{n}{2^i} - \left\lfloor \frac{n}{2^i} \right\rfloor \leq \left[1 - \frac{1}{2^i}\right] \implies $
$\displaystyle \left\lfloor \frac{n}{2^i} \right\rfloor \geq \frac{n}{2^i} - 1 + \frac{1}{2^i}
= \frac{n+1}{2^i} - 1.$
Also, $\displaystyle \frac{1}{2} + \frac{1}{4} + \cdots + \frac{1}{2^r} = 1 - \frac{1}{2^r}.$
Therefore, with $~~n < 2^{(r+1)},~~$ you have that $~~\displaystyle v_2(n!) = \sum_{i=1}^r \left\lfloor\frac{n}{2^i}\right\rfloor $
$\displaystyle \geq (n+1)\left[1 - \frac{1}{2^r}\right] - r = (n - r) + 1 - \frac{n+1}{2^r}.$
Since it is assumed that $~~2^r \leq n < 2^{(r+1)} - 1,~~$ this implies that
$$v_2(n!) > (n - r) + (1 - 2) = (n - r) - 1.\tag3 $$
So, the LHS of (3) above, which is an integer, is strictly greater than $(n - r) - 1.$ Therefore, the LHS of (3) above must be $\geq (n - r).$
Thus, for $2^r \leq n < 2^{(r+1)} - 1,$
$v_2(n!) \geq (n - r) = n - \lfloor\log_2(n+1)\rfloor.$
Thus, it has been proven that:
- $(n-1) \geq v_2(n!)$.
- $v_2(n!) \geq n - \lfloor \log_2(n+1)\rfloor.$