How many natural numbers have $ n$ digits such that the sum of its digits is $ m.$ How many n-digit numbers such that the sum of its digits is $ m.$
My attempt :
We have the gf:
$\begin {align*}
f(x)&=x(1-x^9)(1-x^{10})^{n-1}(1-x)^{-n}\\&=(x-x^{10})(1-x^{10})^{n-1}(1-x)^{-n}
\end{align*}$
Extracting the coefficients of term of $x^m$ in expansion :
$[x^m]f(x)=\left ( [x^{m-1}] -[x^{m-10}]\right )\sum_{k=0}^{n-1 }(-1)^k\binom{n-1}{k}x^k\sum_{l=0}^{n}\binom{l+n-1}{n-1}x^l$
...and I am stuck here please help.
 A: We obtain
\begin{align*}
\color{blue}{[x^m]}&\color{blue}{\left(x-x^{10}\right)\left(1-x^{10}\right)^{n-1}(1-x)^{-n}}\\
&=\left([x^{m-1}]-[x^{m-10}]\right)\sum_{j=0}^{\infty}\binom{-n}{j}(-x)^j\left(1-x^{10}\right)^{n-1}\tag{1}\\
&=\left([x^{m-1}]-[x^{m-10}]\right)\sum_{j=0}^{\infty}\binom{n+j-1}{j}x^j\left(1-x^{10}\right)^{n-1}\tag{2}\\
&=\sum_{j=0}^{m-1}\binom{n+j-1}{j}[x^{m-1-j}]\left(1-x^{10}\right)^{n-1}\\
&\qquad-\sum_{j=0}^{m-10}\binom{n+j-1}{j}[x^{m-10-j}]\left(1-x^{10}\right)^{n-1}\tag{3}\\
&=\sum_{j=0}^{m-1}\binom{n+m-2-j}{m-1-j}[x^j]\left(1-x^{10}\right)^{n-1}\\
&\qquad-\sum_{j=0}^{m-10}\binom{n+m-11-j}{m-10-j}[x^j]\left(1-x^{10}\right)^{n-1}\tag{4}\\
&=\sum_{j=0}^{\left\lfloor\frac{m-1}{10}\right\rfloor}\binom{n+m-2-10j}{m-1-10j}[x^{10j}]\left(1-x^{10}\right)^{n-1}\\
&\qquad-\sum_{j=0}^{\left\lfloor\frac{m-10}{10}\right\rfloor}\binom{n+m-11-j}{m-10-10j}[x^{10j}]\left(1-x^{10}\right)^{n-1}\tag{5}\\
&\,\,\color{blue}{=\sum_{j=0}^{\left\lfloor\frac{m-1}{10}\right\rfloor}\binom{n+m-2-10j}{m-1-10j}\binom{n-1}{j}(-1)^j}\\
&\,\,\color{blue}{\qquad-\sum_{j=0}^{\left\lfloor\frac{m}{10}\right\rfloor-1}\binom{n+m-11-j}{m-10-10j}\binom{n-1}{j}(-1)^j}\tag{6}\\
\end{align*}
Comment:

*

*In (1) we use the binomial series expansion.


*In (2) we use the binomial identity $\binom{-p}{q}=\binom{p+q-1}{q}(-1)^q$.


*In (3) we apply the rule $[x^p]x^qA(x)=[x^{p-q}]A(x)$. We also set the upper limit to $m-1$ resp. $m-10$, since other terms do not contribute.


*In (4) we change the order of summation $j\to m-1-j$ resp. $j\to m-10-j$.


*In (5) we substitute $j$ with $10j$ since the expansion of $\left(1-x^{10}\right)^{n-1}$ contains powers of $x$ which are all multiples of $10$.


*In (6) we select the coefficient of $x^{10j}$.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{{\displaystyle #1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\sr}[2]{\,\,\,\stackrel{{#1}}{{#2}}\,\,\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
Lets the $\ds{n}$-digit number $\ds{a_{1}a_{2}\ldots a_{n}}$ where $\ds{a_{1} \in
\braces{\color{red}{1},2,\ldots,9}}$
and $\ds{\left.\rule{0pt}{5mm}a_{k}\right\vert_{k\ =\ 2,3,\ldots,n}\ \in \braces{0,1,2,\ldots,9}}$ with $\ds{n > 1}$.

The answer is given by
\begin{align}
& \sum_{a_{1} = \color{red}{1}}^{9}
\sum_{a_{2} = 0}^{9}
\sum_{a_{3} = 0}^{9}\cdots\sum_{a_{n} = 0}^{9}
\bracks{z^{m}}z^{a_{1}\ +\ a_{2}\ +\ a_{3}\ +\ \cdots\ +\ a_{n}}
\\[5mm] = & \
\bracks{z^{m}}\pars{\sum_{a_{1} = \color{red}{1}}^{9}
z^{a_{1}}}
\pars{\sum_{a = 0}^{9}z^{a}}^{n - 1}
\\[5mm] = & \
\bracks{z^{m}}\pars{z\,{z^{9} - 1 \over z - 1}}
\pars{z^{10} - 1 \over z - 1}^{n - 1}
\\[5mm] = & \
\bracks{z^{m - 1}}\pars{1 - z^{9}}
\pars{1 - z^{10}}^{n - 1}\,\pars{1 - z}^{-n}
\\[5mm] = & \
\bracks{z^{m - 1}}
\pars{1 - z^{10}}^{n - 1}\,\pars{1 - z}^{-n}\ -
\\[2mm] &\
\bracks{z^{m - 10}}
\pars{1 - z^{10}}^{n - 1}\,\pars{1 - z}^{-n}
\end{align}

In addition,
\begin{align}
& \pars{1 - z^{10}}^{n - 1}\,\pars{1 - z}^{n} \\[5mm] = & \
\sum_{i = 0}^{\infty}{n - 1 \choose i}
\pars{-z^{10}}^{i}
\sum_{j = 0}^{\infty}{-n \choose j}
\pars{-z}^{j}
\\[5mm] = & \
\sum_{i = 0}^{\infty}\sum_{j = 0}^{\infty}
{n - 1 \choose i}{-n \choose j}\pars{-1}^{i + j}
\sum_{k = 0}^{\infty}\delta_{k,10i + j}\,\,\,\, z^{k}
\\[5mm] = & \
\sum_{k = 0}^{\infty}z^{k}
\bracks{\sum_{i = 0}^{\infty}{n - 1 \choose i}
{-n \choose k - 10i}\pars{-1}^{i + k - 10i}\,
\bracks{k - 10i \geq 0}}
\\[5mm] = & \
\sum_{k = 0}^{\infty}z^{k}\pars{-1}^{k}\
\underbrace{\bracks{\sum_{i = 0}^{\left\lfloor k/10\right\rfloor}{n - 1 \choose i}
{-n \choose k - 10i}\pars{-1}^{i}}}
_{\ds{\equiv {\large b_{k}}}}
\end{align}

The final answer is given by:
\begin{align}
& \pars{-1}^{m - 1}\ b_{m - 1} -
\pars{-1}^{m - 10}\ b_{m - 10}
\\[5mm] & 
\bbx{\color{#44f}{\pars{-1}^{m + 1}\pars{~b_{m - 1} + b_{m - 10}~}}} \\ &
\end{align}
