This is the full question:
Consider an integer $n\ge 1$ and the integers $i$,$1\le i \le n$. For each $k=0,1,2,\cdots$, find the number of $i$'s that are divisble by $2^k$ but not by $2^{k+1}$.Thus prove $$ \sum_{j=1}^{\infty} \left[ \frac{n}{2^j}+\frac{1}{2} \right] = n$$ and hence that we get the correct value for the sum $\dfrac{n}{2}+\dfrac{n}{4}+\dfrac{n}{8}+\cdots$ if we replace each term by its nearest integer, using the larger one if two exist. Note: $[x]$ denotes the greatest integer function/floor function of $x$.
This is what i did: The number of integers less that $n$ divisible by $m$ are given by $\left[ \dfrac{n}{m}\right]$, those integers will be $m, 2m, \cdots, \left[ \dfrac{n}{m}\right]m$. Hence for the first part of this question, the answer will be precisely $\left[ \dfrac{n}{2^k}\right]-\left[ \dfrac{n}{2^{k+1}}\right]$. But i am not able to see how this helps in proving the given sum. Also i don't understand what the question is trying to say after we have calculated the sum.
Hint: $\left\lfloor\frac{n}{2^j}+\frac{1}{2}\right\rfloor$ counts the number of $k\in\{1,2,\ldots,n\}$ such that $2^{j-1}\mid k$ but $2^j\nmid k$. In fact, if $m$ is any integer greater than $1$, then $$\sum_{j=1}^\infty\sum_{r=1}^{m-1}\left\lfloor\frac{n}{m^j}+\frac{r}{m}\right\rfloor=n.$$