You are trying to find the amount:
1 + 2 + 4 + ... + 2^i
We see that this is the same as:
2^0 + 2^1 + ... + 2^i
Denote this sum by S(i)
. Looking at the first few values, you can see the pattern:
S(0) = 2^0 = 1 = 1 S(1) = 2^0 + 2^1 = 1 + 2 = 3 S(2) = ... = 1 + 2 + 4 = 7 S(3) = ... = ... = 15 S(4) = ... = ... = 31
We see that they all seem to be one less than 2 degrees. More precisely: S(i)
seems to be equal to 2^(i+1) - 1
. We can prove this by induction:
Base register:
S(0) = 2^(0+1) - 1
We can trivially see that the above statement is true.
Inductive step:
We know that:
S(i) = S(i-1) + 2^(i)
as can be seen from the definition of the amount. In addition, if S(i-1) = 2^(i) - 1
, then:
S(i) = (2^(i) - 1) + 2^(i) = 2*(2^(i)) - 1 = 2^(i+1) - 1
and therefore, we have proved that for all integers i >= 0
, that S(i) = 2^(i+1) - 1
Now, returning to the original question, we are given that 2^i < n
. Then we have:
S(i) = 2^(i+1) - 1 = 2*(2^i) - 1 < 2*n - 1
and therefore we have proved that S (i) 2 * N + 1.
source share