Find the number of solutions of $x+y+z=17$ where $2\le x\le 5, 3\le y \le 6, 4\le z\le7$.
My approach: The number of solutions with the indicated constraints is the coefficient of $x^{17}$ in the expansion of ($x^2+x^3+x^4+x^5)(x^3+x^4+x^5+x^6)(x^4+x^5+x^6+x^7)$
I have changed the above polynomial to $x^9(1+x+x^2+x^3)^3$
Now $x^{17}=x^9*x^8$
So I must now find the coefficient of $x^8$ in the expansion of ($1+x+x^2+x^3)^3$
$x_1+x_2+x_3=8$
This is equal to $C(3+8-1,8)=45$
However it takes into values of $x,y,z$ greater than $3$.
So I must subtract those combinations where either of $x_1,x_2,x_3$ is greater than $3$.
Let's suppose $x_1\ge 4$.Then
$x_1+x_2+x_3=4$ Solutions=$15$.
Similarly for $x_2,x_3$ we get $15$ solutions each. Total=$45$. Now we must consider the case when more than one of $x_1+x_2+x_3\ge 4$. For this we have $3$ solutions.
Total solutions=$48$.
Now I must subtract these from original solutions of $45$. This gives answer $=-3$. But the correct answer is $3$.
What is wrong in this approach?
If $x,y,z \in \mathbb{Z}$ and then the constraints you had; then consider the following case where $x,y,z$ are the most they can be, i.e. $5$, $6$ and $7$:
$$5 + 6 + 7 = 18$$
$18$ is one more than $17$, which means that our solutions will be when only $x$ or only $y$ or only $z$ is one less than their maximum. We have $3$ terms, which means there must be $3$ solutions:
$$(5-1) + 6 + 7 = 17$$ $$5 + (6-1) + 7 = 17$$ $$5 + 6 + (7-1) = 17$$