<s>[INST] How to prove $\sum_{n=0}^{\infty} \frac{n^2}{2^n} = 6$? I'd like to find out why
\begin{align}
\sum_{n=0}^{\infty} \frac{n^2}{2^n} = 6
\end{align}
I tried to rewrite it into a geometric series
\begin{align}
\sum_{n=0}^{\infty} \frac{n^2}{2^n} = \sum_{n=0}^{\infty} \Big(\frac{1}{2}\Big)^nn^2
\end{align}
But I don't know what to do with the $n^2$. 
 [/INST] Observe that
$$\sum_{n=0}^\infty \frac{n^2}{2^n}=2\sum_{n=0}^\infty \frac{n^2}{2^{n+1}}=2E[X^2]$$
where $X$ is a geometric random variable with support $\mathbb{Z}_{\geq 0}$ and  success probability $p=1/2.$ Thus,
$$2E[X^2]=2\left[\text{Var}(X)+(E[X])^2\right]=2\left[\frac{1-p}{p^2}+\left(\frac{1-p}{p}\right)^2\right]=2\frac{(1-p)(2-p)}{p^2}=6.$$
</s>