Here is another solution. We introduce the indicator function notation:
$$ \mathbb{I}[\ldots] = \begin{cases}
1, & \text{if $\ldots$ is true}, \\
0, & \text{if $\ldots$ is false}.
\end{cases} $$
Then
\begin{align*}
S
:= \sum_{k=0}^{\infty} \left\lfloor \frac{n+2^k}{2^{k+1}} \right\rfloor
= \sum_{k=0}^{\infty} \sum_{j=1}^{\infty} \mathbb{I}\left[ j \leq \frac{n+2^k}{2^{k+1}} \right]
= \sum_{k=0}^{\infty} \sum_{j=1}^{\infty} \mathbb{I}\left[ (2j-1)2^k \leq n \right]
\end{align*}
Since every positive integer is uniquely factored into the form $m2^k$, where $m$ is odd and $k \geq 0$, it follows that $i = (2j-1)2^k$ for $j \geq 1$ and $k \geq 0$ represents every positive integer exactly once. Therefore
$$ S = \sum_{i=1}^{\infty} \mathbb{I}\left[ i \leq n \right] = n. $$
\displaystyle
in the question title. See Guidelines for good use of MathJax in question titles. $\endgroup$