<s>[INST] Solving summation $2n+2^2(n-1)+2^3(n-2)+....+2^n$ Can anyone help me with this summation? I tried to use the geometric series on this, but I can't use that.
$$2n+2^2(n-1)+2^3(n-2)+....+2^n$$
I am trying to do this for studying algorithms. Can we get a closed form for this ?
 [/INST] Notice that 
$$S_n=2n+2^2(n-1)+2^3(n-2)+\cdots+2^{n-1}(2)+2^n(1)$$
$$S_{n-1}=2(n-1)+2^2(n-2)+2^3(n-3)+\cdots+2^{n-1}(1)+2^n(0)$$
differ by
$$S_n-S_{n-1}=2+2^2+2^3+\cdots+2^n=2(2^n-1)$$
Therefore, $$S_n=2(2^n-1) + S_{n-1} =2(2^n-1) + 2(2^{n-1}-1) + S_{n-2}$$and so on until
$$S_n=2(2^n-1 +2^{n-1}-1+2^{n-2}-1+\cdots+2^{1}-1)=2([2^1+2^2+\cdots+2^n]-n)$$
You should be able to figure out the answer.
</s>