Combinations sum : $\sum (k+1)^2 \binom{n}{k}$ $$1^2 + 2^2\binom{n}{1} +\ldots+(n+1)^2\binom{n}{n}=?$$
I tried this splitting
$$\sum_{k=0}^n (k+1)^2 \binom{n}{k}=\sum_{k=0}^n (k^2+2k+1) \binom{n}{k}= n^2 \cdot 2^n + 2n \cdot 2^n + 2^n $$
It didn't work for most cases , I then just tried
$$2^n \cdot (n+1)^2  $$
but it also didn't work . So I'm most likely doing it completely wrong or I'm approaching it in the wrong way. Thank you in advance.
 A: You're pulling some unreal magic trick by writing
$$\sum k \binom{n}{k}=n\cdot 2^n , \quad \sum k^2 \binom{n}{k}=n^2\cdot 2^n \tag{✗✗}$$
These of course aren't true.
Instead, by using the identity repeatedly
$$k \binom{n}{k}=n \binom{n-1}{k-1}$$
you can simplify as
$$\sum k \binom{n}{k}=n\sum \binom{n-1}{k-1}=n\cdot 2^{n-1}$$
and
$$\sum k^2 \binom{n}{k}=n\sum k \binom{n-1}{k-1}=$$
$$n\sum (k-1)\binom{n-1}{k-1}+n\sum \binom{n-1}{k-1}=n(n-1) 2^{n-2}+n\cdot 2^{n-1}$$
to yield the final result as
$$\boxed{(n+1)(n+4)\cdot 2^{n-2}}$$

Another approach would be combinatorial method.
Consider a class of $n$ students numbered $1,2,\ldots,n$ along with their teacher. The teacher decides to form a club of any strength, which has a captain and a vice-captain. The teacher must be present in the club and same people are allowed to occupy both positions.
Then we have three cases :

*

*Teacher is both  captain and vice-captain. The students can join or not join the club freely. $1\cdot 2^n$ ways.

*Teacher occupies exactly one position. Then choose one of the students for second position. Other $n-1$ can freely join. $2\cdot n\cdot2^{n-1}$ ways.

*Teacher doesn't occupy any position. Choose the captain and vice-captain. Remaining students can join freely. $n\cdot 2^{n-1}+ n(n-1)\cdot 2^{n-2}$ ways.

Summing, we obtain
$$\boxed{(n+1)(n+4)\cdot 2^{n-2}}$$
A: Splitting it up is a good way to start.  Then use the binomial theorem $$(1+x)^n=\sum_{k=0}^n\binom nk x^k$$
Differentiate both sides to get $$n(1+x)^{n-1}=\sum_{k=0}^n\binom nk kx^{k-1}$$ and set $x=1$.  Then multiply both sides of the last equation by $x$ and differentiate again.
A: You may also try the following approach.
Consider the function $f(a)=\sum_{k=0}^n\binom nk \exp(ak)=\sum_{k=0}^n\binom nk (exp(a))^k=\left(1+\exp(a)\right)^n$.
Then $\sum_{k=0}^n \binom{n}{k}=f(a)|_{a=0}=2^n$
$\sum_{k=0}^nk \binom{n}{k}=\frac{d}{da}f(a)|_{a=0}=n2^{n-1}$
$\sum_{k=0}^nk^2 \binom{n}{k}=\frac{d^2}{da^2}f(a)|_{a=0}=n(n+1)2^{n-2}$, etc.
