3

The question is, how many integers between 1 and 100000 have the sum equal to fifteen?

johnkiko
  • 175
  • 2
    First, do you understand where the $\binom{20}5$ came from? – Brian M. Scott Nov 20 '14 at 20:54
  • Yes, that’s right: it’s the number of solutions in non-negative integers to the equation $$x_1+x_2+x_3+x_4+x_5+x_6=15;,$$ without any upper limit on the sizes of the $x_k$. But some of those solutions have an $x_k$ bigger than $9$, and you have to exclude those. That’s what the second term does. Can you figure out how to calculate the number of solutions that have $x_1>9$? – Brian M. Scott Nov 20 '14 at 21:05
  • The correction term looks to me like $6\binom{11}{6}$. But it would not be the first time I got something off by $1$ in this kind of problem. – André Nicolas Nov 20 '14 at 21:13
  • @johnivan: Yes: each $x_k$ represents one of the $6$ numbers being added to get the total of $15$. Now let’s count the solutions that have $x_1>9$. One easy way is to let $y_1=x_1-10$ and count the non-negative solutions to $$y_1+x_2+x_3+x_4+x_5+x_6=5;;$$ in effect we’re saying that the first ‘digit’ is going to be at least $10$, so that $x_1$ will be $>9$, and $y_1$ is the excess. That excess, plus the other $5$ digits, must add up to $15-10$, as you say. Finally, there are $6$ different positions that could go over $9$, and each gives the same number of ‘bad’ solutions, so we have to ... – Brian M. Scott Nov 20 '14 at 21:21
  • ... multiply by $6$. – Brian M. Scott Nov 20 '14 at 21:22
  • @André: $0$ for the modified variable corresponds to $10$ for the original, not $9$. (I think of it as starting by putting $10$ balls in one pot to start with, leaving $5$ to be distributed arbitrarily.) – Brian M. Scott Nov 20 '14 at 21:23
  • Thanks, I was actually not making that mistake, but a stupider one. – André Nicolas Nov 20 '14 at 22:13

1 Answers1

2

Suppose you write the number $15$ as $a_1+a_2\dots a_n$ where all of the numbers are integers between $1$ and $9$. Then we can make a lot of numbers between $1$ and $1,000,000$ that add up $15$ and whose non-zero digits are precisely $a_1.a_2\dots a_n$ in that order. How many?

The number in question must have $6$ digits or less. So we can add $6-n$ zeroes and look at the non-zero digits as bars to apply a stars and bars argument.

In this way the zeroes are the stars and the non-zero digits are the bars. Therefore there are $\binom{6}{n}$ ways to arrange the zeroes between the non-zero digits. (configurations which have zeroes at the leftmost slots represent those numbers with less digits).

So we can devise a method for counting all the numbers.

Let $f(k)$ be the number of ways to write $15$ as an ordered sum of $k$ integers between $1$ and $9$ that add up to $15$.

Then the solution is $\sum_{k=1}^6f(k)\binom{6}{k}$

How do we calculate $f(k)$?

Notice it is the coeffiecient of $x^{15}$ in the expression $(x+x^2\dots+x^9)^k$


As Brian Points out. The problem amounts to this one:

There are six slots (each of them representing one of the digits). We must distribute $15$ marbles amongst them so that none of them has more than $9$ marbles.

the number of ways to do this is the coefficient of $x^{15}$ in $(1+x+x^2\dots x^9)^6$

Why is that the same as $\binom{20}{5}-6\binom{10}{5}$?

Again a Brian points out there are $\binom{20}{5}$ ways to seperate the $15$ marbles into $6$ boxes by stars and bars without taking into account the size limits.

How many of the ways violate the size limit? Notice at most one of the boxes can have more than $9$ marbles.

How many ways leave box $1$ with more than $9$ marbles?

Assume you have such a configuration. then take away the $10$ marbles from box $1$ and you are left with a distribution of $5$ marbles in $6$ boxes by stars and bars there are $\binom{10}{5}$ of these.

Since there are $6$ option for the box wich has too many $marbles$ we need to substract $6\binom{10}{5}$ from the count.

Asinomás
  • 107,565