As I haven’t finished the posts I’ve planned to write, here is a quick puzzle involving binary numbers:
Compute the total number of one-bits in the binary representations of the numbers 0 to 2n-1 for n from 1 to 50.
For example, for n = 2 we have four different binary representations: 00, 01, 10 and 11. Adding the number of one-bits: 0 + 1 + 1 + 2 = 4.
Hint: it’s quite easy once you get the pattern…