Proof that max value of $n$-bit binary number is $2^n - 1$

1.8k Views Asked by At

After reading this programming question , I wanted to prove the assertion. I'm wondering whether the below would be considered a complete and clear proof.

Claim: $\sum_{i=0}^{n-1} 2^i = 2^n - 1.$

Base Step: $\sum_{i=0}^{0} 2^i = 2^0 = 1 = 2^1 - 1.$ (This corresponds to the case of 1 bit.)

Inductive Step: Assume $\sum_{i=0}^{n-1} 2^i = 2^n - 1.$ Then $\sum_{i=0}^{n} 2^i = (\sum_{i=0}^{n-1} 2^i) + 2^n = (2^n - 1) + 2^n.$ We have $(2^n - 1) + 2^n = 2(2^n) - 1 = 2^{n+1} - 1.$

1

There are 1 best solutions below

0
On

Taken from comments:

You have correctly proved that $\sum_{i=0}^{n-1} 2^i = 2^n - 1.$ To complete the proof of the initial claim, you should elaborate on why $\sum_{i=0}^{n-1} 2^i $ is the greatest number you can make with $n$ bits.