How to find the closed formula for $\sum _{i=0}^n {i q^i}$?
You can use the following transformation:
$$\sum _{i=0}^n {i q^i}=\sum _{i=1}^n {i q^i}=\sum _{i=1}^n {(i-1+1)q^i}=q\sum _{i=1}^n {(i-1)q^{i-1}}+\sum _{i=1}^n {q^i}.$$
Hence
$$S=q(S-nq^n)+\sum _{i=1}^n {q^i}.$$
You should be able to conclude. (Mind the starting indexes.)
More visually:
$$\begin{align}S&=q+2q^2+3q^3+4q^4+\cdots\ \ \ \ \ \ \ \ \ \ \ \ nq^n\\ qS&=\ \ \ \ \ \ \ \ \ q^2+2q^3+3q^4+\cdots\ \ (n-1)q^{n-1}+nq^{n+1}\\ S-qS&=q+\ \ q^2+\ \ q^3+\ \ q^4+\cdots\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ q^n\ \ \ -nq^{n+1}\end{align}$$
Use the fact that $\frac{q^{n+1} - 1}{q-1} = \sum_{i=0}^n q^i$. Now derivate from both sides wrt q and the multiply by $q$ and you will finally get your formula.
$$\begin{align} (n+1)q^{n+1}+\sum_{k=0}^nkq^k & =\sum_{k=0}^{n+1}kq^k \\ & =\sum_{k=1}^{n+1}kq^k \\ & =\sum_{k=0}^n(k+1)q^{k+1} \\ & =\left(q\sum_{k=0}^nkq^k\right)+q\sum_{k=0}^nq^k \\ (n+1)q^{n+1}+\sum_{k=0}^nkq^k & =\left(q\sum_{k=0}^nkq^k\right)+\frac{q(1-q^{n+1})}{1-q} \\ (n+1)q^{n+1} & =\left((q-1)\sum_{k=0}^nkq^k\right)+\frac{q(1-q^{n+1})}{1-q} \\ (q-1)\sum_{k=0}^nkq^k & = (n+1)q^{n+1}-\frac{q(1-q^{n+1})}{1-q} \\ \sum_{k=0}^nkq^k & = \frac{(n+1)q^{n+1}-\frac{q(1-q^{n+1})}{1-q}}{q-1} \end{align}$$