My friend gave me a formula to calculate the sum of numbers with exactly $m$ ones in their binary representation that are less than $2^n$. It is as follows:
$$ {{n-1} \choose {m-1} }* (2^n-1)$$
Is this formula correct? If it is, could you kindly explain the logic behind it? Most probably, the $2^n-1$ comes from a geometric series, so, probably it has something to do with the distribution of the ones, I guess?...
Please help. Thank you.
A hint:
There are ${n\choose m}$ binary numbers having $n$ digits, among them exactly $m$ ones. Exactly ${1\over n}$ of all ones in the big list of these numbers are at the first, ${1\over n}$ at the second, $\ldots$, ${1\over n}$ at the $n^{\rm th}$ digit of the numbers.