How to find number of solutions of an equation? Given $n$, how to count the number of solutions to the equation $$x + 2y + 2z = n$$ where $x, y, z, n$ are non-negative integers?
 A: 1) If $n$ is even, with $n=2m$, then $x$ is also even.  If we let $x=2x^{\prime}$, we have
$x^{\prime}+y+z=m$, which has $\binom{m+2}{2}$ solutions where $m=\frac{n}{2}$.
1) If $n$ is odd, with $n=2m+1$, then $x$ is also odd.  If we let $x=2x^{\prime}+1$, we have
$x^{\prime}+y+z=m$, which has $\binom{m+2}{2}$ solutions where $m=\frac{n-1}{2}$.
A: We can restate this as:
$$x=n-2y-2z=n-2(y+z)$$
$y$ and $z$ are non-negative integers, so $y+z \geq 0$. We also have $x$ is a non-negative integer, so $n-2(y+z) \geq 0$, or $y+z \leq \lfloor \frac{n}{2} \rfloor$. Thus, we need to figure out the number of positive integers $y, z$ that satisfy:
$$0 \leq y+z \leq \left\lfloor \frac{n}{2} \right\rfloor$$
Now, if $y+z=0$, we have only one solution: $0+0$
If $y+z=1$, we have two solutions: $0+1=1+0$
If $y+z=2$, we have three solutions: $0+2=1+1=2+0$
From this pattern, we find that if $y+z=m$, we have $m+1$ solutions.
We need to sum $m+1$ from $m=0$ to $m=\lfloor \frac{n}{2} \rfloor$ since those are the possible values for $y+z$, so our answer is:
$$\sum_{m=0}^{\lfloor \frac{n}{2} \rfloor} m+1$$
We can say $k=m+1$ to change this sum to:
$$\sum_{k=1}^{\lfloor \frac{n}{2} \rfloor+1} k$$
Using the sum of consecutive positive integers identity, we get:
$$\frac{\left(\lfloor \frac{n}{2} \rfloor+1\right)\left(\lfloor \frac{n}{2} \rfloor+1+1\right)}{2}={\lfloor \frac{n}{2} \rfloor+2 \choose 2}$$
A: Note that $n$ and $x$ must be the same parity; either both odd, or both even. The number of solutions to $n=2k$ and  $n=2k+1$ are thus the same; the difference between the two solution sets is only that the value of $x$ is increased by one in the odd-$n$ solutions. 
So considering those two cases together, $n=2k$ or $n=2k+1$, then the answer is a partition question to find out how to express $k$ as an ordered sum of three non-negative integers. This is a simple matter of placing the separators (stars & bars), so the number of possible solutions is $${k+2\choose 2}$$
The first value obtained needs to be multiplied by two and, if $n$ is odd, increased by $1$ to get the value of $x$. The partition produces $y$ and $z$ directly.
A: $\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\iff}{\Leftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\color{#f00}{\sum_{x = 0}^{\infty}\sum_{y = 0}^{\infty}\sum_{z = 0}^{\infty}
\delta_{x + 2y + 2z\,,n}} =
\sum_{x = 0}^{\infty}\sum_{y = 0}^{\infty}\sum_{z = 0}^{\infty}
\oint_{\verts{w} = 1^{-}}{1 \over w^{n + 1 - x - 2y - 2z}}
\,{\dd w \over 2\pi\ic}
\\[3mm] = &\
\oint_{\verts{w} = 1^{-}}{1 \over w^{n + 1}}
\sum_{x = 0}^{\infty}w^{x}\sum_{y = 0}^{\infty}\pars{w^{2}}^{y}
\sum_{z = 0}^{\infty}\pars{w^{2}}^{z}\,{\dd w \over 2\pi\ic}
\\[3mm] = &\
\oint_{\verts{w} = 1^{-}}{1 \over w^{n + 1}}\,{1 \over 1 - w}
\,{1 \over 1 - w^{2}}\,{1 \over 1 - w^{2}}\,{\dd w \over 2\pi\ic} =
\oint_{\verts{w} = 1^{-}}{1 \over w^{n + 1}\pars{1 - w}^{3}\pars{1 + w}^{2}}\,{\dd w \over 2\pi\ic}
\\[3mm] \stackrel{z\ \to\ 1/z}{=}\ &\
\oint_{\verts{w} = 1^{\color{#f00}{+}}}
{w^{n + 4} \over \pars{w - 1}^{3}\pars{w + 1}^{2}}\,{\dd w \over 2\pi\ic} =
\underbrace{{1 \over 2!}\,\lim_{w \to 1}\partiald[2]{}{w}{w^{n + 4} \over \pars{w + 1}^{2}}}
_{\ds{2n^{2} + 10n + 11 \over 16}}\ +\ \underbrace{%
{1 \over 1!}\,\lim_{w \to -1}\partiald{}{w}{w^{n + 4} \over \pars{w - 1}^{3}}}
_{\ds{\pars{-1}^{n}\,{2n + 5 \over 16}}}
\\[5mm] = &\
\color{#f00}{{2n^{2} + 2\bracks{5 + \pars{-1}^{n}}n +
\bracks{11 + 5\pars{-1}^{n}} \over 16}}
\end{align}
$$
\mbox{A few values:}\quad
\left\lbrace\begin{array}{rclcr}
\ds{n} & \ds{=} & \ds{0,1} & \ds{\imp} & \ds{1}
\\
\ds{n} & \ds{=} & \ds{2,3} & \ds{\imp} & \ds{3}
\\
\ds{n} & \ds{=} & \ds{4,5} & \ds{\imp} & \ds{6}
\\
\ds{n} & \ds{=} & \ds{6,7} & \ds{\imp} & \ds{10}
\\
\ds{n} & \ds{=} & \ds{8,9} & \ds{\imp} & \ds{15}
\\
\ds{n} & \ds{=} & \ds{10} & \ds{\imp} & \ds{21}
\end{array}\right.
$$
A: We need the coefficient of $x^n$ in $(1+x+x^2+\cdots)(1+x^2+x^4+\cdots)^2$.
This can be written as 
\begin{align*}
\frac{1}{(1-x)(1-x^2)^2} &= \frac{1}{(1-x)^3(1+x)^2} \\
&= \frac{1/4}{(1-x)^3}+\frac{1/4}{(1-x)^2}+\frac{3/16}{1-x}+\frac{1/8}{(1+x)^2}+\frac{3/16}{1+x}
\end{align*}
The required coefficient is 
$$ \frac{1}{4}\binom{n+2}{n}+\frac{1}{4}\binom{n+1}{n}+\frac{3}{16}(n+1)+\frac{(-1)^n}{8}\binom{n+1}{n}+\frac{3(-1)^n}{16}$$
