Calculate $\displaystyle\sum_{k=1}^n \frac{k^2}{2^k}$ Calculate $\sum _{k=1}^n\:\frac{k^2}{2^k}$
I got $\sum _{k=1}^n\:\frac{k^2}{2^k} = (1+2+ \dots +k + \dots +n-1+n)(1+\frac{1}{2} + \dots +\frac{1}{2^{k-1}}+ \dots +\frac{1}{2}^{(n-1)}-\frac{n}{2^n})$. Not sure how to simplify further. 

Firstly, 
$$\sum_{k=1}^n\ \frac k{2^k}=\sum_{k=1}^n\ \left(\frac k{2^{k-1}}-\frac {k+1}{2^k}+\frac 1{2^k}\right)=1-\frac {n+1}{2^n}+\sum_{k=1}^n\ \frac 1{2^k}=2-\frac {n+2}{2^n}$$ .
On the other hand, 
$$\sum_{k=1}^n\ \frac {k^2}{2^k}=\sum_{k=1}^n\ \left(\frac {k(k+1)}{2^k}-\frac k{2^k}\right)=\sum_{k=1}^n\ \left(\frac {k^2}{2^{k-1}}-\frac {(k+1)^2}{2^k}+\frac {3k+1}{2^k}\right)-\left(2-\frac {n+2}{2^n}\right)=$$
$$=\left(1-\frac {(n+1)^2}{2^n}\right)-\left(2-\frac {n+2}{2^n}\right)+3\sum_{k=1}^n\ \frac k{2^k}+\sum_{k=1}^n\ \frac 1{2^k}=$$
$$=\frac {-n^2-n+1}{2^n}-1+3\cdot\left(2-\frac {n+2}{2^n}\right)+\left(1-\frac 1{2^n}\right) = 6-\frac{n^2+4n+6}{2^n}$$
