<s>[INST] Find all $4$ digit numbers such that sum of digits is $11$. Find all $4$ digit numbers such that sum of digits is $11$.
\begin{cases} x_1+x_2+x_3+x_4=11\\ 1\leq x_1{\leq 9}\\ 0\leq x_2{\leq 9}\\0\leq x_3{\leq 9}\\ 0\leq x_4{\leq 9}\end{cases}.
Using  stars and bars there is 13 choose 3 ways to do. So we get $286$ but answer is $279$. I saw this same question in the forum but didn't fully understand solution. Where we are overcounting when solving in this way? And mainly what we are overcounting?
 [/INST] In this answer it is described how to solve this by generating functions. The solution is the coefficient of the degree $11$ monomial of the polynomial
$$(x+x^2+\cdots+x^9)(1+x+x^2+x^3+\cdots+x^9)^3$$
This coefficient can be calculated by a CAS like  Mathematica as shown in the link above. It can even calculated by a numerical calculator that can handle arbitrary length integers as describe in the second half of my answer here. But in this answer I learned in one of the comments how to calculate this by hand.
Note that
$$\frac 1 {1-x}=\sum_{n=0}^\infty x^n$$
and by differentiation using induction you get
$$\frac 1 {(1-x)^k}=\sum_{n=0}^\infty{ n+k-1 \choose k-1} x^n$$
So we have
$$(x+x^2+\cdots+x^9)(1+x+x^2+x^3+\cdots+x^9)^3\\
=x\frac{1-x^9}{1-x}\frac{(1-x^{10})^3}{(1-x)^3}\\
=x(1-x^9)(1-x^{10})^3 \sum_{n=0}^\infty{ n+3 \choose 3} x^n\\
=(x-x^{10}-3x^{11}+3x^{20}+\cdots)\frac 1 6 (1\cdot2\cdot3+2\cdot 3 \cdot4\cdot x+\cdots+11\cdot 12\cdot 13\cdot x^{10} \cdots )\\
=\cdots +\cdot \frac 1 6 (-3\cdot 1\cdot 2 \cdot 3-2\cdot 3\cdot 4+11\cdot 12 \cdot 13)x^{11}+\cdots\\
=\cdots+279x^{11}+\cdots$$
The coefficients of the monomials of degree greater than $36$ cancel out.
We have
$$
\frac{\left( {{x}^{40}}-{{x}^{31}}-3 {{x}^{30}}+3 {{x}^{21}}+3 {{x}^{20}}-3 {{x}^{11}}-{{x}^{10}}+x\right) \, \sum_{n=0}^{\infty }{\left. \left( {{n}^{3}}+6 {{n}^{2}}+11 n+6\right)  {{x}^{n}}\right.}}{6}
$$
We abbreviate
$$f(n):={{n}^{3}}+6 {{n}^{2}}+11 n+6$$
and verify that
$$f(n+39)-f(n+30)-3f(n+29)+3f(n+20)+3f(n+19)-3f(n+10)-f(n+9)+f(n)=0$$
and
$$f(n+39)-f(n+30)-3 f(n+29)+3 f(n+20)+3 f(n+19)-3 f(n+10)-f(n+9)$$
for $n=-1,-2,-3$ because $f(n)=0$ for this values
</s>