(I've asked similar question, but this is much more complicated, I think)

What is the sum of $\sum\limits_{i=1}^{n}i^k p^i$?

Interpretation (why is it important ) :
$f(k,n,p)=\sum\limits_{i=1}^{n}i^k p^i$
if n goes to plus infinity, then $f(1,n,1/2)$ is average length or series of heads while tipping symmetric coin, and $f(2,n,1/2)-f(1,n,1/2)^2$ is the variance of that length, so for another k we get k-th moment