How many positive integers less than 10000 have the sum of their digits equal to 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.
We can count this using generating functions. We create a generating funciton where the exponent counts the digit sum and the coefficient counts how many numbers have that digit sum. For a single digit, the generating series is 1 + x + x 2 + x 3 + x 4 + x 5 + x 6 + x 7 + x 8 + x 9 , so for 4 digits, the generating series will be ( 1 + x + x 2 + x 3 + x 4 + x 5 + x 6 + x 7 + x 8 + x 9 ) 4 . We want the coefficient of x 1 5 from this expression. We provide 2 methods for calculating this.
Method 1:
We can write ( 1 + x + x 2 + x 3 + x 4 + x 5 + x 6 + x 7 + x 8 + x 9 ) 4 as
= ( 1 + x 5 ) 4 ( 1 + x + x 2 + x 3 + x 4 ) 4 ( 1 + 4 x 5 + 6 x 1 0 + 4 x 1 5 + x 2 0 ) ( 1 + 2 x + 3 x 2 + 4 x 3 + 5 x 4 + 4 x 5 + 3 x 6 + 2 x 7 + x 8 ) 2
Since we want the coefficient of x 1 5 from this expression, we just need the coefficients of x 1 5 , x 1 0 , x 5 , x 0 from the second term, since only terms that multiply with terms from the first expression to give x 1 5 are relevant.
The coefficient of x 0 is 1.
The coefficient of x 5 is 1 × 4 + 2 × 5 + 3 × 4 + 4 × 3 + 5 × 2 + 4 × 1 = 5 2 .
The coefficient of x 1 0 is 3 × 1 + 4 × 2 + 5 × 3 + 4 × 4 + 3 × 5 + 2 × 4 + 1 × 3 = 6 8 .
The coefficient of x 1 5 is 2 × 1 + 1 × 2 = 4 .
So, the coefficient of x 1 5 in the whole expression is 1 × 4 + 4 × 6 8 + 6 × 5 2 + 4 × 1 = 5 9 2 .
Method 2:
We can write ( 1 + x + x 2 + x 3 + x 4 + x 5 + x 6 + x 7 + x 8 + x 9 ) 4 as ( 1 − x 1 − x 1 0 ) 4 = ( x 4 0 − 4 x 3 0 + 6 x 2 0 − 4 x 1 0 + 1 ) ( 1 − x ) − 4
Since we want the coefficient of x 1 5 from the expression, we only need the coefficients of x 1 5 and x 5 from ( 1 − x ) − 4 to calculate this. Using the negative binomial theorem, the coefficient of x 1 5 is ( 3 1 8 ) = 8 1 6 and the coefficient of x 5 is ( 3 8 ) = 5 6 . So the coefficient of x 1 5 in the overall expression is 1 × 8 1 6 + ( − 4 ) × 5 6 = 5 9 2