DEV Community

Discussion on: Power Up Your Programming With This Simple Equation

Collapse
 
dividedbynil profile image
Kane Ong

If you like to save 4 mins of reading time, here's the summary:

Given an integer n, find the sum of 20 + 21 + ... + 2n.

If you speak binary, and knowing that:
10 - 1 = 1
100 - 1 = 11
1000 - 1 = 111

if n = 4, the answer will be 24+1 - 1.

You're welcome.