Digit Sum till 999999??!?!?!?

Level pending

How many natural numbers 999 , 999 \le 999,999 have a digit sum equal to 20?


The answer is 35127.

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

Kartik Sharma
Nov 30, 2014

To do this problem, I would use a technique known as generating function

Let digits be d 1 , d 2 , d 3 , d 4 , d 5 , d 6 {d}_{1}, {d}_{2}, {d}_{3}, {d}_{4}, {d}_{5}, {d}_{6}

and d 1 + d 2 + d 3 + d 4 + d 5 + d 6 = 20 {d}_{1} + {d}_{2} + {d}_{3} + {d}_{4} + {d}_{5} + {d}_{6} = 20 and 0 d i 9 0 \le {d}_{i} \le 9 .

Now, we will generate a function -

f ( x ) = ( 1 + x + x 2 + x 3 + x 4 + x 5 + . . . . . x 8 + x 9 ) 6 f(x) = {(1 + x + {x}^{2} + {x}^{3} + {x}^{4} + {x}^{5} +..... {x}^{8} + {x}^{9})}^{6}

And the coefficient of x 20 {x}^{20} in f ( x ) f(x) is our answer.

f ( x ) = ( 1 x 10 ) 6 1 x 6 f(x) = \frac{{(1-{x}^{10})}^{6}}{{1-x}^{6}}

( 1 x ) n = 1 + ( n + 1 1 1 ) x + ( n + 2 1 2 ) x 2 + . . . . . ( n + r 1 r ) x r . . . {(1-x)}^{-n} = 1 + \left( \begin{matrix} n+1-1 \\ 1 \end{matrix} \right)*x + \left( \begin{matrix} n+2-1 \\ 2 \end{matrix} \right)*{x}^{2} +..... \left( \begin{matrix} n+r-1 \\ r \end{matrix} \right)*{x}^{r}...

Hence,

f ( x ) = ( ( 1 x 10 ) 6 ) ( 1 + ( 6 + 1 1 1 ) x + ( 6 + 2 1 2 ) x 2 + . . . . . ( 6 + r 1 r ) x r . . . ) f(x) = ({(1-{x}^{10})}^{6})*(1 + \left( \begin{matrix} 6+1-1 \\ 1 \end{matrix} \right)*x + \left( \begin{matrix} 6+2-1 \\ 2 \end{matrix} \right)*{x}^{2} +..... \left( \begin{matrix} 6+r-1 \\ r \end{matrix} \right)*{x}^{r}...)

This is simple binomial expansion - ( 1 x 10 ) 6 {(1-{x}^{10})}^{6}

And so, the coefficient of x 20 {x}^{20} is the sum of coefficients of

  • ( x 20 {x}^{20} in 1st part of product) * ( x 0 {x}^{0} in 2nd part of product)

  • ( x 0 {x}^{0} in 1st part of product) * ( x 20 {x}^{20} in 2nd part of product)

  • ( x 10 {x}^{10} in 1st part of product) * ( x 10 {x}^{10} in 2nd part of product)

Hence,

coefficient of x 20 {x}^{20} in the product = ( 6 2 ) ( 6 + 10 1 10 ) ( 6 1 ) + ( 6 + 20 1 20 ) \left( \begin{matrix} 6 \\ 2 \end{matrix} \right) -\left( \begin{matrix} 6+10-1 \\ 10 \end{matrix} \right) \left( \begin{matrix} 6 \\ 1 \end{matrix} \right) +\left( \begin{matrix} 6+20-1 \\ 20 \end{matrix} \right)

= ( 6 2 ) ( 6 + 10 1 10 ) ( 6 1 ) + ( 6 + 20 1 20 ) \left( \begin{matrix} 6 \\ 2 \end{matrix} \right) -\left( \begin{matrix} 6+10-1 \\ 10 \end{matrix} \right) \left( \begin{matrix} 6 \\ 1 \end{matrix} \right) +\left( \begin{matrix} 6+20-1 \\ 20 \end{matrix} \right)

= 35127 \boxed{35127}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...