Find explicit formula for summation I have this summation: $\displaystyle\sum_{i=1}^{\log_2 n} 2^{i}$, any suggestion of how get an explicit formula? 
 A: 
We obtain
  \begin{align*}
\sum_{i=1}^{\log_2 n} 2^{i}&=\sum_{i=1}^{\lfloor\log_2 n\rfloor} 2^{i}\tag{1}\\
&=2\frac{1-2^{\lfloor\log_2 n\rfloor}}{1-2}\tag{2}\\
&=2\left(2^{\lfloor\log_2 n\rfloor}-1\right)
\end{align*}
In the special case $n=2^k$ the formula simplifies to $2^{k+1}-2$.

Comment:


*

*In (1) we note that the index range of the sum are integer values. So, the upper limit is the greatest integer less or equal to $\log_2 n$. This can be denoted with  the floor function $\lfloor\log_2 n\rfloor$.

*In (2) we use the formula for the finite geometric series
\begin{align*}
\sum_{i=1}^{n}a^i=a\frac{1-a^n}{1-a}
\end{align*}
A: First of all you will need $n$ to be a power of $2$ for for the sum to exist. For simplicity I'll write $\log_2 n=k$ and then you will get
$2+2^2+2^3+\cdots+2^{k}$
And if you factor out $2^k$ you have $1+\frac{1}{2}+\frac{1}{2^2}+\cdots+\frac{1}{2^{k-1}}$ which is a geometric sum equal to $\frac{1-\frac{1}{2^k}}{1-\frac{1}{2}}=\frac{2^k-1}{2^k-2^{k-1}}$. Hope I didnt mess up that algebra but you get the idea.
A: Assuming n is a power of 2, the formula will be $2n-2$.
Intuitively, if you have $2+4+8+16+32+...+n$, all of the numbers preceding n will add up to 2 less than n, so the sum will be $2n-2$.
