Finding general formula of $\sum_{i=0}^n i^2 \binom{n}{i}$

Solution 1:

HINT:

$$r^2\cdot\binom nr=r(r-1)\cdot\binom nr+r \cdot\binom nr=n(n-1)\cdot\binom{n-2}{r-2}+n\cdot\binom{n-1}{r-1}$$

Now set $a=b=1$ in the following identity $$\sum_{r=0}^m(a+b)^m=\sum_{r=0}^m\binom mr a^{m-r}b^r$$