-3

How to solve:$\sum\limits_{i=0}^{x-1} {2^i} = N$ e.g. if N=15, then x=4.

lucky1928
  • 159

2 Answers2

4

Let's look at what the sum is, indicating term by term. The first ones are

$$S = 1 + 2 + 4 + 8 + 16 + 32 + 64 + \ldots + 2^{x-1}$$

$$S = 1 + 2(1 + 2 + 4 + 8 + \ldots + 2^{x-2})$$

$$S = 1 + 2\left(S - 2^{x-1}\right)$$

$$S = 1 + 2S - 2^x$$

$$S - 2S = 1 - 2^x$$

$$S = 2^x - 1$$

Hence your sum is equal to $2^x-1$

Which means

$$2^x - 1 = N$$

Taking the log base 2

$$\log_2(2^x) = \log_2(N+1)$$

$$\boxed{x = \log_2(N+1)}$$

hakeem
  • 107
Enrico M.
  • 26,114
2

Using the formulae for geometric series summation,$$\begin{align} & \sum\limits_{i=0}^{x-1} {2^i} = N \\ \implies & 2^0+\ldots +2^{x-2}+2^{x-1} = N \\ \implies & 2^0\cdot\frac{2^x-1}{2-1}=N \\ \implies & 2^x-1=N \\ \implies & \color{blue}{x=\log_2 (N+1)}\end{align}$$

EDIT: In step-$2$, we have used the following theory:

For ${\displaystyle} r\neq 1$, the sum of the first n terms of a geometric series is

$${\displaystyle} a+ar+ar^{2}+ar^{3}+\cdots +ar^{n-1}=\sum _{k=0}^{n-1}ar^{k}=a\,{\frac {1-r^{n}}{1-r}}$$ where $a$ is the first term of the series, and $r$ is the common ratio. We can derive this formula as follows:

$${\displaystyle} {\begin{aligned}s&=a+ar+ar^{2}+ar^{3}+\cdots +ar^{n-1},\\rs&=ar+ar^{2}+ar^{3}+ar^{4}+\cdots +ar^{n},\\s-rs&=a-ar^{n},\\s(1-r)&=a(1-r^{n}),\end{aligned}}$$ So,

$${\displaystyle} s=a\cdot {\frac {1-r^{n}}{1-r}}\quad {\text{(if }}r\neq 1{\text{)}}.$$

  • Of course, the solution only makes sense if $x$ is a non-negative integer... – Thomas Andrews Nov 04 '16 at 18:26
  • @ThomasAndrews Well, yes. Point to be noted and assumed since the dummy index conventionally does not assume negative integers. – SchrodingersCat Nov 04 '16 at 18:29
  • Great, still not understand the step (2). How do we get it from step (1)? – lucky1928 Nov 04 '16 at 18:38
  • @lucky1928 Updated my answer. I have provided the general theory. Please insert $r=2$ and $n=x$ as is required for this problem. – SchrodingersCat Nov 04 '16 at 18:43
  • Well, my point is that, after solving an equation, you have to make sure that it actually makes sense. So the answer is $x=\log_2(N+1)$ when this is a non-negative integer. This is much like squaring an equation and then forgetting to go back and "check" your solutions, and students should be reminded of that... – Thomas Andrews Nov 04 '16 at 19:28