Too many numbers

Find number of positive integers less than 1 0 8 10^{8} with digit sum of 24.

Bonus : Generalize this problem.


The answer is 1708575.

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.

1 solution

To find sum of all numbers with digit sum S S & less than 1 0 r 10^{r}

Consider an r digited number with digit sum S.
Let it's digits be x 1 , x 2 , x r x_{1} , x_{2} \ldots, x_{r}
9 x i 0 9 \ge x_{i} \ge 0
x 1 + x 2 + x 3 + x r = S \therefore x_{1} + x_{2} + x_{3} + \ldots x_{r} = S
Notice, if we put the first m digits = 0 0 we simply get an r m r-m digit number, so all the numbers are included that is, 1 1 digit numbers, 2 2 digit numbers, \ldots , r digit numbers.
The number of ways this can be done ( N ) is given by the co-efficient of x S x^{S} in the expansion of ( x 0 + x 1 x 9 ) ( x 0 + x 1 x 9 ) r times = ( 1 + x 1 + x 2 x 9 ) r = ( 1 x 10 1 x ) r \underbrace{\left(x^{0} + x^{1} \ldots x^{9}\right)\ldots\left(x^{0} + x^{1} \ldots x^{9}\right)}_\text{r times} = \left(1 + x^{1} + x^{2} \ldots x^{9}\right)^{r} = \left( \dfrac{1-x^{10}}{1-x}\right)^{r}
N = ( 1 x 10 ) r ( 1 x ) r \therefore N = \left(1-x^{10}\right)^{r}\left(1-x\right)^{-r}
Using the binomial expansion for the first bracket,
N = ( m = 0 r ( 1 ) m ( r m ) x 10 m ) × ( 1 x ) r N = \displaystyle \left( \sum_{m=0}^{r}(-1)^{m}\dbinom{r}{m}x^{10m} \right) \times (1-x)^{-r}
Consider the Taylor series of 1 1 x \dfrac{1}{1-x}
1 1 x = k = 1 r x k + r 1 \dfrac{1}{1-x} = \displaystyle \sum_{k=1-r}^{\infty}x^{k+r-1}


Differentiating ( r 1 ) (r-1) times,
( r 1 ) ! ( 1 x ) r = k = 0 ( ( k + r 1 ) ( k + r 2 ) ( k + 1 ) ) x k \dfrac{(r-1)!}{(1-x)^{r}} = \displaystyle \sum_{k=0}^{\infty}\left((k+r-1)(k+r-2)\ldots(k+1)\right)x^{k}
( 1 x ) r = k = 0 ( ( k + r 1 ) ( k + r 2 ) ( k + 1 ) ) x k ( r 1 ) ! = k = 0 ( k + r 1 r 1 ) x k (1-x)^{-r} = \displaystyle \sum_{k=0}^{\infty}\dfrac{\left((k+r-1)(k+r-2)\ldots(k+1)\right)x^{k}}{(r-1)!} = \displaystyle \sum_{k=0}^{\infty}\dbinom{k+r-1}{r-1}x^{k}
Therefore, co-efficient of x k x^{k} = ( k + r 1 r 1 ) \dbinom{k+r-1}{r-1}
Therefore co-effcient of x S 10 m x^{S-10m} = ( S 10 m + ( r 1 ) r 1 ) \dbinom{S-10m+(r-1)}{r-1}
\therefore Co-efficient of x S x^{S} in ( 1 x 10 ) r ( 1 x ) r (1-x^{10})^{r}(1-x)^{r} = m = 0 m i n ( S 10 , r ) ( 1 ) m ( r m ) ( S 10 m + ( r 1 ) r 1 ) \displaystyle \sum_{m=0}^{min\left(\left\lfloor\dfrac{S}{10}\right\rfloor, r\right)} (-1)^{m} \dbinom{r}{m} \dbinom{S-10m+(r-1)}{r-1}

The reason for the upper limit being, 10 × ( S 10 + 1 ) > S 10 \times \left( \left \lfloor\dfrac{S}{10} \right\rfloor +1\right) > S

N = m = 0 m i n ( S 10 , r ) ( 1 ) m ( r m ) ( S 10 m + ( r 1 ) r 1 ) \therefore N = \displaystyle \sum_{\displaystyle m=0}^{min\left(\left\lfloor\dfrac{S}{10}\right\rfloor, r\right)} (-1)^{m} \dbinom{r}{m} \dbinom{S-10m+(r-1)}{r-1}

For using this in the given question , S = 24 , r = 8 S = 24, r = 8
N = m = 0 24 10 ( 1 ) m ( 8 m ) ( 24 10 m + 7 7 ) \therefore N = \displaystyle \sum_{\displaystyle m=0}^{\left\lfloor\dfrac{24}{10}\right\rfloor} (-1)^{m} \dbinom{8}{m} \dbinom{24-10m+7}{7}
N = m = 0 2 ( 1 ) m ( 8 m ) ( 31 10 m 7 ) \therefore N = \displaystyle \sum_{\displaystyle m=0}^{\displaystyle 2} (-1)^{m} \dbinom{8}{m} \dbinom{31-10m}{7}

N = ( 31 7 ) 8 ( 21 7 ) + 28 ( 11 7 ) = 2629575 930240 + 9240 \therefore N = \dbinom{31}{7} - 8\dbinom{21}{7} + 28\dbinom{11}{7}= 2629575 - 930240 + 9240
N = 1708575 \therefore N = 1708575

I used CS.

A Former Brilliant Member - 5 years, 5 months ago

Log in to reply

How long did it take?

Shaun Leong - 5 years, 5 months ago

Log in to reply

5 minutes. Patience is key.

A Former Brilliant Member - 5 years, 5 months ago

That's nice too!

A Former Brilliant Member - 5 years, 5 months ago

We can simply use principle of exclusion and inclusion. First we distribute 24 identical things to 8 different places then subtract the cases in which at least 1 of them has get 10 or more things then add those cases when 2 of them have got 10 or more things. By solving this we get 31C7 - 8C1 * 21C7 + 8C2 * 11C7. By solving this we get 1708575.

Archit Agrawal - 5 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...