Find the number of integers between 1 and whose sum of digits is 15.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Since 1 0 6 has a digit sum of 1 , we can look at the set of six-digit "numbers" a b c d e f for integers 0 ≤ a , b , c , d , e , f ≤ 9 . With this formatting, the integer 1 0 2 , for example, is represented by the six-digit "number" 0 0 0 1 0 2 , and in fact there is a one-to-one correspondence between these six-digit "numbers" and the integers between 1 and 1 0 6 . ( 1 ≡ 0 0 0 0 0 1 has a digit sum of 1 so it is not of importance that it is included in this formatting.)
The number of integer solutions we are looking for are then the number of solutions to the equation
a + b + c + d + e + f = 1 5 , 0 ≤ a , b , c , d , e , f ≤ 9 , ... (A).
Now look at the companion equation a ′ + b ′ + c ′ + d ′ + e ′ + f ′ = 1 5 with 0 ≤ a ′ , b ′ , c ′ , d ′ , e ′ , f ′ ≤ 1 5 , ...(A'). This is a "stars and bars" equation, and thus has ( 6 − 1 1 5 + 6 − 1 ) = ( 5 2 0 ) solutions. The difference between equations (A) and (A') is the range of possible values for the variables, with the effect that any solution for (A') which involves any of its variables having a value of 1 0 or more will not be a solution for (A). So to find the number of solutions to (A) we need to subtract from ( 5 2 0 ) those solutions of (A') that involve variables taking on a value of 1 0 or more.
Now we can only have one of a ′ , b ′ , c ′ , d ′ , e ′ , f ′ be 1 0 or more in a given solution to (A'), since then the greatest value any other variable could have is 1 5 − 1 0 = 5 . So we can look at the number of solutions with a ′ equalling, in turn, 1 0 , 1 1 , 1 2 , 1 3 , 1 4 , 1 5 , and then multiply by 6 , (to account for those solutions that have each of b ′ , c ′ , d ′ , e ′ , f ′ take on these values, (all mutually exclusive)), to find the number of solutions to (A') that are not also solutions to (A).
In general, with a ′ = 1 0 + k , 0 ≤ k ≤ 5 , we then have the associated equation
b ′ + c ′ + d ′ + e ′ + f ′ = 5 − k with 0 ≤ b ′ , c ′ , d ′ , e ′ , f ′ ≤ 5 − k
to solve. As these are "stars and bars" equations we know that in general there are
( 5 − 1 ( 5 − k ) + 5 − 1 ) = ( 4 9 − k ) associated solutions. So the number of solutions to (A) is
( 5 2 0 ) − 6 ∗ k = 0 ∑ 5 ( 4 9 − k ) = ( 5 2 0 ) − 6 ∗ ( ( 4 9 ) + ( 4 8 ) + ( 4 7 ) + ( 4 6 ) + ( 4 5 ) + ( 4 4 ) ) =
1 5 5 0 4 − 6 ∗ ( 1 2 6 + 7 0 + 3 5 + 1 5 + 5 + 1 ) = 1 5 5 0 4 − 6 ∗ 2 5 2 = 1 3 9 9 2 solutions.
(Note that we can simplify the calculation by employing the hockey stick identity
i = r ∑ n ( r i ) = ( r + 1 n + 1 ) where n > r .
Then k = 0 ∑ 5 ( 4 9 − k ) = i = 4 ∑ 9 ( r i ) = ( 4 + 1 9 + 1 ) = ( 5 1 0 ) .
Thus our calculation can be simplified to ( 5 2 0 ) − 6 ∗ ( 5 1 0 ) = 1 5 5 0 4 − 6 ∗ 2 5 2 = 1 3 9 9 2 as before.)