math Common summations in computer science Sums of Powers of Two: 1 + 2 + 4 + 8 + 16 + ...


Example

The sum

20 + 21 + 22 + ... + 2n-1

simplifies to 2n - 1. This explains why the maximum value that can be stored in an unsigned 32-bit integer is 232 - 1.