[Math] Permutation and combination and binary numbers

binarycombinationspermutations

what is the sum(in base 10) of all natural numbers less than 64 which have exactly three ones in their base 2 representation.
answer given -630
I just need a starting point like from where should I start any hint?? Also I know only basic binary-decimal conversions so please answer accordingly.

Best Answer

Well, since there are only $63$ natural numbers less than $64$, one way you could proceed is by brute force. These are the numbers that can be represented in binary by six bits. There are therefore only $\binom{6}{3} = 20$ different numbers that qualify. Write them all out, and then add them.

A slightly more clever way to proceed is to consider how many numbers have a $1$ in the most significant binary (MSB) position—the one corresponding to decimal $32$. That leaves two bits to go in the remaining five positions. There are $\binom{5}{2} = 10$ of those, so the MSB position contributes $320$. That isn't the sum of those ten numbers, but it is the sum of the contribution of that bit from those ten numbers.

Similarly, there are ten qualifying numbers that contain the second most significant bit, so they contribute $160$, and so on to the least significant bit. What is the total contribution?