<s>[INST] Find the number of integers solutions How many solutions are there to the equation $$x_1+x_2+x_3+x_4=39,$$
I) where $x_1,x_2,x_3,x_4$ are nonnegative integers,
II) where $x_1,x_2,x_3,x_4$ are nonnegative integers such that $3 \leq x_1,x_2,x_3 \leq 12$ and $0 \leq x_4$.
I) There is a 1-1 correspondence between the solutions and reordering of 39 ones and 3 zeros. Hence the answer is $\binom{42}{3}$
I did not understand very well this type of solution. What about the second case?
 [/INST] Assume $a$ as a real number, such that $0<a <1$ 
I.
 The number of integral solutions should be the same as:
The coefficient of $a ^ {39}$ in
$ \left(1+a + a^{2} + a^{3} + ... \right)^4$
Which is coeffient of $a^{39}$ in the series for
$ \left(1-a\right)^{-4}$
which is $\binom{39+4}{3}$

II.
Answer is same as the coefficient of $a ^ {39}$ in
$ \left(a^{3} + a^{4} + a^{5} + a^{6} + ... + a^{12} \right)^3\left(1+a + a^{2} + a^{3} + ... \right)$
= coeffient of $a^{30}$ in
$ \left(1+a+a^2+a^3+ ... + a^{9} \right)^3\left(1+a + a^{2} + a^{3} + ... \right)$
= coeffient of $a^{30}$ in
$ \left(1-a^{10}\right)^3\left(1-a\right)^{-4}$
= coeffient of $a^{30}$ in
$ \left(1-3a^{10} + 3a^{20} -a^{30}\right)\left(1-a\right)^{-4}$
Since  $\left(1-a\right)^{-4}$ is
$1 +\binom{3+1}{3}a+\binom{3+2}{3}a^3+\binom{3+3}{3}a^3+ ...$
Ignore all powers more than 30
Answer
$= \binom{33}{3}-3\binom{23}{3}+3\binom{13}{3}-\binom{3}{3}$
</s>