<s>[INST] How many natural solutions to $x_1+x_2+x_3+x_4=100$ with $x_1 \neq x_2 \neq x_3 \neq x_4$? I have invented a little exercise of combinatorics that I can't solve (without brute forcing): in how many ways can I choose 4 non-negative integers, the sum of which is 100 and they are all different? So:
$x_1+x_2+x_3+x_4=100$
$x_1, x_2, x_3, x_4 \in \mathbb N$
$x_1 \neq x_2 \neq x_3 \neq x_4$
I have thought that the result have to be the number of total combination $\binom {100 + 4 - 1} {4 - 1}$ minus the ways I can solve $2x_1 + x_2 + x_3 = 100$. Anyway, I am not able to solve it either.
The solution should be:

 161664 or $\binom {100 + 4 - 1} {4 - 1} - 15187 = 176851 - 15187 = 161664$

Does anyone know how to calculate the combinations of this problem?
 [/INST] Here is a solution with generating functions. Let $a_n$ be the number of objects you wish to count, namely the ordered quadruples of distinct non-negative integers with a sum of $n$, and let $f(x)=\sum_{n\ge0}a_nx^n$ be the ordinary generating function of this sequence. Since the integers in the sum are distinct, this generating function must be
 $$f(x)=\left[\frac{y^4}{4!}\right]\prod_{n\ge0}(1+yx^n).$$
 Then the problem of computing $a_n$ is reduced to finding the coefficient $[x^n]f(x)$. You can do this with standard techniques, but it does take some persistence! The result is an explicit formula for $a_n$, and in particular for $a_{100}$, as requested.
First, since sums are more familiar to me than products, I'll change the product to a sum by way of exponentials and logarithms:
 $$f(x)=\left[\frac{y^4}{4!}\right]\exp\bigl(\sum_{n\ge0}\log(1+yx^n)\bigr).$$
 Since we'll eventually extract the coefficient of $y^4$, we can expand the logarithm in its Taylor series up through the 4-th order powers of $y$, using $\log(1+t)\approx t-\frac12t^2+\frac13t^3-\frac14t^4$, and then sum the resulting geometric series:
 \begin{eqnarray*}
 % \nonumber to remove numbering (before each equation)
   f(x) &=& \left[\frac{y^4}{4!}\right]\exp\bigl(\sum_{n\ge0}yx^i-\frac12y^2x^{2i}+\frac13y^3x^{3i}-\frac14y^4x^{4i} \bigr)\\
    &=& \left[\frac{y^4}{4!}\right]\exp\bigl(\frac y{1-x}-\frac12\,\frac{y^2}{1-x^2}+\frac13\,\frac{y^3}{1-x^3}-\frac14\,\frac{y^4}{1-x^4}\bigr).
 \end{eqnarray*}
At this stage, it's slightly easier to replace the exponential of the sum  with the product of the exponentials. Then we'll expand each exponential in its Taylor series (again  through the 4-th order powers of $y$), using $\exp(t)\approx1+t+\frac12t^2+\frac1{3!}t^3+\frac1{4!}t^4$:
 \begin{eqnarray*}
 % \nonumber to remove numbering (before each equation)
   f(x) &=& \left[\frac{y^4}{4!}\right]\exp\bigl(\frac y{1-x}\bigr) \exp\bigl(-\frac12\frac{y^2}{1-x^2}\bigr)
   \exp\bigl(\frac13\frac{y^3}{1-x^3}\bigr) \exp\bigl(-\frac14\frac{y^4}{1-x^4}\bigr) \\
 &=& \left[\frac{y^4}{4!}\right]\left( 1+\frac y{1-x}+ \frac12\frac{y^2}{(1-x)^2}+ \frac16\frac{y^3}{(1-x)^3}+\frac1{24}\frac{y^4}{(1-x)^4}\right)\times\\
   &&\quad \left( 1-\frac12\,\frac{y^2}{1-x^2}+\frac18\frac{y^4}{(1-x^2)^2}\right) \times\left( 1+\frac13\,\frac{y^3}{1-x^3}\right) \times\left( 1-\frac14\,\frac{y^4}{1-x^4}\right) .
 \end{eqnarray*}
 In the expansion of this product, there are just five terms with a coefficient of $y^4$, so
 $$ f(x)=\frac 8{(1-x)(1-x^3)}-\frac6{(1-x)^2(1-x^2)}
 +\frac1{(1-x)^4}+\frac3{(1-x^2)^2}-\frac6{1-x^4}.$$
Using basic facts about series expansions of rational functions, it is straightforward to compute the coefficient of $x^n$ in each of the five terms, resulting in
\begin{eqnarray*}
% \nonumber to remove numbering (before each equation)
  a_n &=&[x^n]f(x) \\
    &=& 8\left(\lfloor n/3\rfloor+1\right)   -\frac32\bigl(\{1\text{ if }2|n\}+ (n+3)(n+1)\bigr)+\\
            &&\frac{(n+3)(n+2)(n+1)}{6}+3\left\{n/2+1\text{ if } 2|n\right\}-6\left\{1\text{ if }4|n\right\}.
\end{eqnarray*}
As in other calculations, this gives $a_{100}=161\,664$.
</s>