What is the number of solutions for $x+y+z = n^2$ for $x,y,z$ non-negative integers?
I thought to use generating functions. I know that the generating function for $x_1+x_2+...+x_k= n$ when $x_i \in S_i$ for $i \in \{1,2,...k\}$ is $$\sum_{n=0}^{\infty}a_nx^n=\prod_{i=0}^{k}(\sum_{n\in S_i}x^n) $$ based in that can I say that the generating function for the number of solutions for $x_1+x_2+...+x_k= n^2$ is $$\sum_{n=0}^{\infty}a_nx^n=(\prod_{i=0}^{k}(\sum_{n\in S_i}x^n))^2 $$
If not, is there a different way to find the number of solutions for the equation above?
EDIT:
I added another variable, so now the number of solutions for this equation, because I wanted to ask about the general case