# How many solutions are there to $x+y+z=n$? Need help understanding the answer. [duplicate]

I need some help. I do not understand how to get the answer (solution) to this question. I could not solve it, neither did it help when I saw the answer. This is a question from the chapter combinatorics from my textbook. Should be noted that my textbook has not be explaining anything that resembles this kinds of questions. So I am stuck. I would appreciate some insights. Thanks.

The question:

Let $n \in \mathbb{Z^+}$. How many solutions are there to the equation: $$x+y+z=n$$ such that $x,y,z \in \mathbb{N}$?

$\frac{1}{2}(n^{2} + 3n + 2)$

How did they arrive at this answer?

## marked as duplicate by Ian Miller, Parcly Taxel, Tom-Tom, N. F. Taussig, PragabhavaOct 7 '16 at 16:14

• You may want to check Stars and bars. You could also check this post. – StubbornAtom Oct 7 '16 at 10:10
• This has been asked many times, please perform a search of stars and bars. – Jack D'Aurizio Oct 7 '16 at 10:11
• @notmyrealname It's not some advanced tecnhique. All you need is some basic logic and combinatorics. – Stefan4024 Oct 7 '16 at 10:24
• Applying the formula we get $\binom{n+2}{2}=\frac{n^2+3n+2}{2}$ – StubbornAtom Oct 7 '16 at 10:45
• The answer you have provided is for non-negative $x,y,z$. For just finding out the answer remember that $\binom{n+k-1}{k-1}$ is the number of non-negative integral solutions of $x_1+x_2+...+x_k=n$, and $\binom{n-1}{k-1}$ is the number of positive integral solutions of the same equation. – StubbornAtom Oct 7 '16 at 10:56

Considering $$z(x,y) = n-x-y$$
where $x,y\in \mathbb{N}\cup \{ 0 \}$ and $x+y\leq n$