The Number $p(n)$ of triplets $(x,y,z)$ : $x+2y+3z=n$ I need some ideas for studying Diophantine equation (linear or exponential ) with elementary probability. For example this one : 

Find the Number $p(n)$ of triplets $(x,y,z)\in\mathbb{N}^3$ such that $x+2y+3z=n$.

 A: For any $n\in\mathbb{N}$, we have:
$$ \left|\{(x,y,z)\in\mathbb{N}^3:x+2y+3z=n\}\right|\\=[w^n](1+w+w^2+\ldots)(1+w^2+w^4+\ldots)(1+w^3+w^6+\ldots)\tag{1}$$
hence we have to compute the coefficient of $w^n$ in $\frac{1}{(1-w)(1-w^2)(1-w^3)}$. Let $\omega=e^{2\pi i/3}=\frac{1+i\sqrt{3}}{2}$.
By partial fraction decomposition:
$$\begin{eqnarray*} f(w)&=&\frac{1}{(1-w)(1-w^2)(1-w^3)}\\ &=& \frac{17w^2-52w+47}{72(1-w)^3}+\frac{1}{8(1+w)}+\frac{\omega}{9(w-\omega^2)}+\frac{\omega^2}{9(w-\omega)}\tag{2}\end{eqnarray*}$$
hence the coefficient of $w^n$ is given by the closest integer to $\color{red}{\frac{1}{72} \left(47+36 n+6 n^2\right)}$.
A: Idea. Let define the following formal power series: $$f:=\sum_{n=0}^{+\infty}p_nX^n.$$
One has: $$f=\frac{1}{(1-X)(1-X^2)(1-X^3)}.$$
Indeed, notice that: $$\frac{1}{(1-X)(1-X^2)(1-X^3)}=\left(\sum_{n=0}^{+\infty }X^n\right)\left(\sum_{n=0}^{+\infty}X^{2n}\right)\left(\sum_{n=0}^{+\infty}X^{3n}\right).$$
Expanding and reducing the right member of the previous equality gives you the expression of $f$.
