As titled, I need to find number of solutions to the equation $a+b+c=0$, where $a,b,c$ are integers in the range $[-k,k]$.($k$ is a positive integer) and $a$ doesn't equal to $0$.
My attempt: let $$x=a+k, y=b+k, z=c+k$$ we need to find non-negative solutions to the equation $$x+y+z=3k$$ with $$0\leq x,y,z\leq 2k.$$ Using the formula, there are $\left(\frac{3k+3-1}{3-1}\right)$=$\left(\frac{3k+2}{2}\right)$ solutions.
We then erase the cases where one of them is $>2k$ (only one of them can be $>2k$).
Let $$x'= x-(2k+1)$$ then x' is non-negative, number of solutions to the equation: $$x'+y+z=k-1$$ is:
$$\left(\frac{k+3-1}{3-1}\right)$$
But this gives a total of $3k^2-2$ solutions if we calculate $\left(\frac{3k+2}{2}\right)$-$3 \cdot \left(\frac{k+2}{2}\right)$,which is not the desired answer. And I haven't delete the case where $a=0$
What did I do wrong? Any help will be appreciated.
\binom
.$\binom{k+3-1}{3-1}$
gives $\binom{k+3-1}{3-1}$ – saulspatz Mar 01 '21 at 06:14