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.

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}$.
