# 6.6 #20 How many integers between 1 and 1,000,000 have the sum

6.6 #20 How many integers between 1 and 1,000,000 have the sum of the digits equal to 15?

We begin by noting that the sum of the digits of 1,000,000 is 1, not 15, so we may only count the integers between 1 and 999,999. Write each of these integers using 6 digits, i.e. 12 is now 000012.

We may represent each above integers whose digits sum to 15 in the following way: look at the first digit and draw a number of Ds equal to the value of this digit. Then draw a * and continue to the next digit. For example, when you are done the integer 230361 will have the representation (* stands for a space)

D D * D D D * * D D D * D D D D D D * D

We may count ”good” integers between 1 and 999,999 by counting the number of arrangements of these Ds and *s.

The total number of arrangements of 5 *s and 15 Ds is

20

. (We have to

5 choose 5 places of 20 in which to put the *s.) Unfortunately this is not the whole story. Suppose we try to construct a number and we place 10 or more Ds in sequence. For example:

D D D D D D D D D D * D * D * D * D * D

The first set of Ds should correspond to the first digit of our number but there are 10 Ds and there is no digit of value 10. So we need to rule out these

Suppose that the first group of Ds is ”bad”. Then the first 10 places must be Ds. We then put the 5 *s in the last 10 places. For example:

D D D D D D D D D D

← first ten place 5 *s → D D * * * D D D * *

Each configuration thus produced is bad, and each bad configuration with the first group of Ds having 10 or more Ds will be created by this method. Thus we get

10

Now notice that there can only be 1 ”bad” group of Ds – if one group contains

10 or more than the remaining Ds number 5 or less. Each group created with 5 or less Ds is ”good”. The ”bad” group may be the first, second, third, fourth, fifth, or sixth group. Each of these events are mutually exclusive so we can use the addition principle. This reasoning gives the number of bad configurations equal to 6

10

5

. So the number of good configurations is

20

5

6

10

5

1