# Why is $\sum_{i=0}^{w-1}{2^i} = 2^w - 1$?

by That Guy   Last Updated September 11, 2019 18:20 PM - source

The title says it all, I guess. Why $$\sum_{i=0}^{w-1}{2^i} = 2^w - 1$$

Tags :

Here is an intuitive way to see it:

Say you want to compute $$1+2+2^2+2^3+2^4\tag{1}$$ If you add $$1$$ to the sum $$(1)$$ you'll get: $$(1+1)+2+2^2+2^3+2^4\\=(2+2)+2^2+2^3+2^4\\=(2^2+2^2)+2^3+2^4\\=(2^3+2^3)+2^4\\=(2^4+2^4)\\=2^5$$

Since we added $$1$$, the sum is $$1$$ less, that is, $$2^5-1$$

cansomeonehelpmeout
September 11, 2019 17:51 PM

Say we set $$s_n(x)=\sum_{k=0}^{n-1}x^k.$$ We see that $$s_{n+1}(x)=x^n+s_n(x).$$ But we also see that $$xs_n(x)=\sum_{k=0}^{n-1}x^{k+1}=\sum_{k=1}^{n}x^k=s_{n+1}(x)-1.$$ Hence we have $$xs_n(x)=s_n(x)+x^n-1,$$ which means that for $$x\ne 1$$, $$s_n(x)=\frac{x^n-1}{x-1}.$$ The sum in question is given by $$\sum_{i=0}^{w-1}2^i=s_{w}(2)=\frac{2^w-1}{2-1}=2^w-1.$$

clathratus
September 11, 2019 18:01 PM

Here's another way to look at it. \begin{align}S=1+&2+4+8+\cdots+2^n\\ 2S=\ \ &2+4+8+\cdots+2^n+2^{n+1}\end{align} Subtract the first equation from the second to get $$S=2^{n+1}-1$$

saulspatz
September 11, 2019 18:02 PM