# How many integer solutions are there to $x+y+z=8$

How many integer solutions are there to $$x+y+z=8$$ When $$x,y,z>0$$? When $$x,y,z\geq -3$$?

So I know there is a formula for computing the number of nonnegative solutions

$${8+3-1 \choose 3-1}={10\choose 2}$$

So I then just subtracted cases where one or two integers are $$0$$.

If just $$x=0$$ then there are $$6$$ solutions where neither $$y,z=0$$.

So I multiplied this by $$3$$, then added the cases where two integers are $$0$$

$$3\cdot 6+3=21$$. So I get $${10 \choose 2}+21=66$$

For the last problem where $$x,y,z\geq -3$$ I'm not sure how to deal with it.

• I would try $-3\le x,y,z\le0$, then add it to the solutions you already have. – R. Burton Feb 12 at 22:57

Note you can use the same method for the first question: if $$x+y+z=8$$ and $$x,y,z>0$$, you can set $$x=1+x', y=1+y', z=1+z'$$, where $$x',y',z'$$ are nonnegative and $$x'+y'+z'=5$$.

Therefore the number of positive solutions is $$\;\dbinom{5+3-1}{3-1}=\dbinom 72=21.$$

More generally, it is easy to prove that the number of positive integer solutions of the equation $$x_1+x_2+\dots +x_r=n \quad (n\ge r)$$ is equal to $$\;\dbinom{n-1}{r-1}$$.

• @N.F.Taussig: One never rereads oneself carefully enough… Fortunately, others do it for you! Thank you for pointing it! – Bernard Feb 12 at 23:18
• What solutions am I missing here then? The pairs I should have where one integer is $0$ is $(1,7),(2,6),(3,5),(4,4)$ which gives me $8$ solutions where only one integer is $0$. Multiply that by $3$ for each case, $24$. Then there are three remaining solutions where two are $0$ and one is $8$. Gives me $27$ solutions which have a nonnegative. $45-27=18$. – AColoredReptile Feb 12 at 23:41
• You have $7$ solutions when only one integer is $0$, plus the three solutions with two integers equal to $0$, so you have to subtract $3\times 7+2=24$. Furthermore, in your post, you added instead of subtracting. – Bernard Feb 12 at 23:51

For the second problem, write $$x=-3+x'$$ and so on. You have $$x'+y'+z'=17$$ and $$x',\dots$$ are nonnegative, a case you know how to solve.

You can also solve the first problem this way; now you would set $$x=1+x'$$, etc.

Start by looking at the number of solutions of $$\begin{eqnarray*} X+Y+Z=17 \end{eqnarray*}$$ which has $$\binom{17+3-1}{3-1}$$ solutions.

This is the same as the number of solutions of $$\begin{eqnarray*} x+y+z=8 \end{eqnarray*}$$ where $$x=X-3$$,$$y=Y-3$$ and $$z=Z-3$$.

Your answer to the question of how many solutions the equation $$x + y + z = 8 \tag{1}$$ has in the positive integers is incorrect. As a sanity check, observe that there must be fewer solutions to the equation in the positive integers than there are in the nonnegative integers since we are not allowed to substitute $$0$$ for any of the variables.

How many integer solutions are there to the equation $$x + y + z = 8$$ when $$x, y, z > 0$$?

If $$x, y, z$$ are positive integers, then $$x' = x - 1$$, $$y' = y - 1$$, and $$z' = z - 1$$ are nonnegative integers. Substituting $$x' + 1$$ for $$x$$, $$y' + 1$$ for $$y$$, and $$z' + 1$$ for $$z$$ in equation 1 yields \begin{align*} x' + 1 + y' + 1 + z' + 1 & = 8\\ x' + y' + z' & = 5 \tag{2} \end{align*} Equation 2 is an equation in the nonnegative integers with $$\binom{5 + 3 - 1}{3 - 1} = \binom{7}{2}$$ solutions. Notice that there are fewer solutions to equation 1 in the positive integers than the nonnegative integers, as we would expect.

How many integer solutions are there to the equation $$x + y + z = 8$$ when $$x, y, z \geq -3$$?

If $$x, y, z \geq -3$$, then $$x' = x + 3$$, $$y' = y + 3$$, and $$z' = z + 3$$ are nonnegative integers. Substitute $$x' + 3$$ for $$x$$, $$y' + 3$$ for $$y$$, and $$z' + 3$$ for $$z$$ in equation 1, then proceed as above.