Computing $\sum_{k = 1}^{n} \dfrac{k}{2^k} $ in different ways I am trying to compute the following sum \begin{align} S = \sum_{k = 1}^{n} \dfrac{k}{2^k} \end{align}
I have computed this sum and found that
$$ \bbox[5px,border:2px solid red]
{
S = 2 - \dfrac{n+2}{2^{n}} 
}
$$
For prooving this let's rewrite the sum in the following way:
\begin{align} S = \dfrac{1}{2} + \dfrac{1 + 1}{2^2} + \dfrac{1+1+1}{2^3} + \ldots + \dfrac{1+ \ldots+1}{2^n} = \bbox[5px,border:2px solid yellow]
 {\dfrac{1}{2} + \dfrac{1}{2^2} + \ldots + \dfrac{1}{2^n}} + \bbox[5px,border:2px solid yellow]
{ \dfrac{1}{2^2} + \dfrac{1}{2^3} + \ldots+\dfrac{1}{2^n}} + \ldots + \bbox[5px,border:2px solid yellow]{
\sum_{j = k}^{n}\dfrac{1}{2^j}} + \ldots +\bbox[5px,border:2px solid yellow]{
 \dfrac{1}{2^n}} = \sum_{j = 1}^{n}\left( \dfrac{1}{2^{k-1}} - \dfrac{1}{2^n}  \right) =  2 - \dfrac{1}{2^{n-1}} - \dfrac{n}{2^n}  =2 - \dfrac{n+2}{2^{n}} \end{align}
This computations are rather awfull and i made them just to find the answer, and i am looking for another interesting ways how to compute this sum (especcialy not elementary, using calculus, or number theory, or theory of functions of complex variable, or something else), any ways will be very appriciated!

First, compute the value of a geometric series
$$
T_n = \sum_{k=1}^n (1/2)^k .
\tag1$$
We can multiply by $1/2$ to get
$$
\frac{1}{2} T_n = \sum_{k=1}^n (1/2)^{k+1} = \sum_{k=2}^{n+1} (1/2)^k
\tag2$$
Compute $(1) - (2)$:
$$
T_n - \frac{1}{2}T_n =  \sum_{k=1}^{n} (1/2)^k- \sum_{k=2}^{n+1} (1/2)^k
\\
\frac{1}{2} T_n = (1/2) - (1/2)^{n+1}
$$
so
$$
T_n = 1 - (1/2)^{n}
\tag3$$
Now let's go on to compute
$$
S_n = \sum_{k=0}^n k (1/2)^k
\tag4$$
(Starting at $k=0$ makes no difference.)
As before, multiply by $1/2$
$$
\frac{1}{2} S_n = \sum_{k=0}^n k (1/2)^{k+1} = \sum_{k=1}^{n+1} (k-1) (1/2)^k
\tag5$$
Subtract $(4)-(5)$
$$
S_n - \frac{1}{2} S_n = \sum_{k=0}^n k (1/2)^k - \sum_{k=1}^{n+1} (k-1) (1/2)^k
\\
\frac{1}{2} S_n = 0 + \sum_{k=1}^n (1/2)^k - n(1/2)^{n+1}
\\
\frac{1}{2} S_n = 0 + T_n - n(1/2)^{n+1}
\\
\frac{1}{2} S_n = 0 + 1-(1/2)^n - n(1/2)^{n+1}
$$
so
$$
S_n = 2 -(2+n)(1/2)^n
$$
