How many positive integer solutions are there to the equality $x_1+x_2+…+x_r= n$?

The original problem is there are $r$ identical boxes and $n$ identical balls. Every box is nonempty. Then how many ways of putting balls in boxes?

It is equivalent to the problem of finding integer solutions for the equality:
$$x_1+x_2+…+x_r= n$$
and $x_i>0$ for all $1\leq i\leq r$.

Editted by @Sil: Replaced with equality to avoid confusion that this question deals with $x_1+x_2+\dots+x_r\leq n$, which it does not!

Solutions Collecting From Web of "How many positive integer solutions are there to the equality $x_1+x_2+…+x_r= n$?"

If $r>n$ this cannot be done.

Otherwise,
write $n = 1+ 1 +1+1+ \dots + 1+1+1$ and choose $r-1$ ‘plus signs’ in this string. In this way you are
writing $n$ as a sum $(1+ \dots +1) + (1+\dots +1) + \dots + (1+\dots +1) = x_1 + x_2 + \dots + x_r$.

This means that you have to choose $r-1$ elements in a set of $n-1$ elements, so the answer is
$\binom{n-1}{r-1}$.

I guess you mean how many ways there are to put the balls in the boxes, otherwise it is r!.
The problem you state is equivalent to $x_1+x_2+…+x_r=n$ with $x_i\ge a_i$ where $a_i$ is some non-negative integer constant (representing the balls that are in the box). Then you should make the equivalent “easy form” with setting $y_i=x_i-a_i$, then $y_i\ge 0$ and the initial equation takes the form $y_1+y_2+…+y_r=n-\sum_{i=1}^{r}a_i$. The number of solutions are ${r+n-\sum_{i=1}^{r}a_i-1}\choose{n-\sum_{i=1}^{r}a_i}$

I prefer thinking this as a dynamic programming problem

$f(n,r)=\sum_{i=1} ^{n-r} f(n-i,r-1)$ and $f(1,1)=1$. Here $f(n,r)$ means the number of ways to seperate $n$ into $r$ parts. Then we can think this as moving in a two-dimensional matrix ($n \times $r). To move to the upper right grid $(n,r)$ from $(1,1)$. Every step, you can mover up a row but can move right random columns less than $n-r$. This is equal to assign $(n-1)$ balls to $(r-1)$ bins.