Find number of positive integers less than with digit sum of 24.
Bonus : Generalize this problem.
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.
To find sum of all numbers with digit sum S & less than 1 0 r
Consider an r digited number with digit sum S.
Let it's digits be x 1 , x 2 … , x r
9 ≥ x i ≥ 0
∴ x 1 + x 2 + x 3 + … x r = S
Notice, if we put the first m digits = 0 we simply get an r − m digit number, so all the numbers are included that is, 1 digit numbers, 2 digit numbers, … , r digit numbers.
The number of ways this can be done ( N ) is given by the co-efficient of x S in the expansion of r times ( x 0 + x 1 … x 9 ) … ( x 0 + x 1 … x 9 ) = ( 1 + x 1 + x 2 … x 9 ) r = ( 1 − x 1 − x 1 0 ) r
∴ N = ( 1 − x 1 0 ) r ( 1 − x ) − r
Using the binomial expansion for the first bracket,
N = ( m = 0 ∑ r ( − 1 ) m ( m r ) x 1 0 m ) × ( 1 − x ) − r
Consider the Taylor series of 1 − x 1
1 − x 1 = k = 1 − r ∑ ∞ x k + r − 1
Differentiating ( r − 1 ) times,
( 1 − x ) r ( r − 1 ) ! = k = 0 ∑ ∞ ( ( k + r − 1 ) ( k + r − 2 ) … ( k + 1 ) ) x k
( 1 − x ) − r = k = 0 ∑ ∞ ( r − 1 ) ! ( ( k + r − 1 ) ( k + r − 2 ) … ( k + 1 ) ) x k = k = 0 ∑ ∞ ( r − 1 k + r − 1 ) x k
Therefore, co-efficient of x k = ( r − 1 k + r − 1 )
Therefore co-effcient of x S − 1 0 m = ( r − 1 S − 1 0 m + ( r − 1 ) )
∴ Co-efficient of x S in ( 1 − x 1 0 ) r ( 1 − x ) r = m = 0 ∑ m i n ( ⌊ 1 0 S ⌋ , r ) ( − 1 ) m ( m r ) ( r − 1 S − 1 0 m + ( r − 1 ) )
The reason for the upper limit being, 1 0 × ( ⌊ 1 0 S ⌋ + 1 ) > S
∴ N = m = 0 ∑ m i n ( ⌊ 1 0 S ⌋ , r ) ( − 1 ) m ( m r ) ( r − 1 S − 1 0 m + ( r − 1 ) )
For using this in the given question , S = 2 4 , r = 8
∴ N = m = 0 ∑ ⌊ 1 0 2 4 ⌋ ( − 1 ) m ( m 8 ) ( 7 2 4 − 1 0 m + 7 )
∴ N = m = 0 ∑ 2 ( − 1 ) m ( m 8 ) ( 7 3 1 − 1 0 m )
∴ N = ( 7 3 1 ) − 8 ( 7 2 1 ) + 2 8 ( 7 1 1 ) = 2 6 2 9 5 7 5 − 9 3 0 2 4 0 + 9 2 4 0
∴ N = 1 7 0 8 5 7 5