I'm trying to prove this by mathematical induction, but I just can't seem to get the answer that I should be getting. Here's what I have so far:
Let $P(n)$ be the statement (this is the equation that I'm supposed to prove by induction): $$\sum_{i=0}^n (n-i)2^i = 2^{n+1}-n-2,$$ Basis step: $(n=0)$: $$P(0) = (0-0)2^0 = 2^{0+1}-0-2 = 0 = 0.$$ Inductive step: Assume that $P(n)$ is true, that is, $$\sum_{i=0}^n (n-i)2^i = 2^{n+1}-n-2.$$
Showing that $P(n+1)$ is also true, that is: $$\sum_{i=0}^{n+1} (n-i)2^i = 2^{n+2}-(n+1)-2 $$ $$ = 2^{n+2}-n-3 $$ $P(n+1) ={}$ $$\sum_{i=0}^{n+1} (n-i)2^i + n-(n+1)2^{n+1}$$ $$ = 2^{n+1}-n-2+(n-n-1)2^{n+1} $$ $$ = 2^{n+1}-n-2-(1)2^{n+1}$$
As can be seen, I am not getting back the result I'm supposed to be getting for $P(n+1)$. Can someone assist me here, please?
Given $$P(\color{red}n)=\sum_{i=0}^\color{red}n (\color{red}n-i)2^i,$$ note: $$\begin{align}P(\color{red}0)=&\sum_{i=0}^\color{red}0 (\color{red}0-i)2^i = (\color{red}0-0)2^0=0=2^{\color{red}0+1}-\color{red}0-2; \ \ \text{(base step)}\\ P(\color{red}1)=&\sum_{i=0}^\color{red}1 (\color{red}1-i)2^i = (\color{red}1-0)2^0+(\color{red}1-1)2^1=1;\\ \vdots\\ P(\color{red}{n})=&\sum_{i=0}^{\color{red}{n}} (\color{red}{n}-i)2^i=\color{blue}{2^{n+1}-n-2}; \ \ \text{(inductive hypothesis)}\\ P(\color{red}{n+1})=&\sum_{i=0}^{\color{red}{n+1}} (\color{red}{n+1}-i)2^i =\\ =&\sum_{i=0}^n (n+1-i)2^i+\require{cancel} \cancel{(n+1-(\color{red}{n+1}))2^{n+1}}=\\ =&\sum_{i=0}^n(n-i)2^i+\sum_{i=0}^n2^i=\\ =&\color{blue}{2^{n+1}-n-2}+2^{n+1}-1=\\ =&2^{n+2}-(n+1)-2.\end{align}$$