1

I have been looking at some simpler versions where digits sum < 9 example: from 1 to $10^4$ how many sum to 5? using repeated combinations $$\binom{5+5−1}{5}=\binom{9}{5}=126$$ however the given answer is 56

does a generalized version (formula) exist where R = sum of digits ; N = number of digits. $$ A \leq N \leq B $$

in the example above$$ R = 5; N = 5; A = 1; B = 5; $$

Arturo Magidin
  • 398,050
RK12345
  • 11
  • 1

1 Answers1

2

Your error is that the numbers between $1$ and $10^4$ don't have 5 digits; they have at most $4$ digits, except for the largest one, $10^4 = 10000$, whose digits don't add up to $5$.

Instead, you need to count the number of $4$-tuples that add up to $5$; these will correspond to numbers between $0$ ($=0000$) and $9999$ whose digits add up to $5$. So the correct formula would be $$\binom{4+5-1}{5} = \binom{8}{5} = 56.$$ Your binomial coefficient counts, instead, the number between $1$ and $10^5$ whose digits add up to $5$ (by counting those between $0$ and $99,999$).

Arturo Magidin
  • 398,050
  • aha thx! i am still wondering if there is a generalized version (maybe using hockey stick identity etc..because as soon as the sum of digits cross 10 i have to keep subtracting wrong ones...kinda like this one.. http://math.stackexchange.com/questions/65934/how-many-numbers-between-100-and-900-have-sum-of-their-digits-equal-to-15 –  Feb 23 '12 at 20:22
  • The analysis in Brian Scott's answer is easily generalizable; I think you will have to do it by subtraction, though, rather than some simple "direct" formula. – Arturo Magidin Feb 23 '12 at 21:24