How to guess the value of $j$ at the end of the loop? for ( i = n , j = 0 ; i &gt; 0 ; i = i / 2 , j = j + i ) ;


All variables are integers.(i.e. if decimal values occur, consider their floor value)

Let $\text{val}(j)$ denote the value of $j$, after the termination of the loop. Which of the following is true?

(A)$\quad \text{val(j)} = \Theta(\log(n)) $ 
(B)$\quad \text{val(j)} = \Theta(\sqrt n) $ 
(C)$\quad \text{val(j)} = \Theta(n) $ 
(D)$\quad \text{val(j)} = \Theta(\log\log n) $

Please explain, is there any easy way to guess the value of $j$?
If you unfold the loop you get:

$$\text{val}( j)=n+n/2+n/4+ n/8 \ldots$$

In total you have $\log n$ terms.
See this post, how to evaluate the sum.