What is the coefficient of $x^n$ in the expansion of $(1+x+x^2+x^3+\dots)^4$? I have just come across a question (in a past exam paper for a module that I will be taking soon) which asks what the coefficient of $x^n$ is in the expansion of
$$
(1+x+x^2+x^3+x^4+\dots)^4
$$
Can anyone give me an idea as to how this might be done? Using Wolfram Alpha to expand the brackets and then by inspecting the coefficient of each power manually, I was able to deduce that the coefficient of $n^\text{th}$ term is given by $C(n+2, 3)$. How might I have been able to work this out for myself?

Combinatoric Approach
Suppose that we pick $x^a$ from the first factor of $\left(1+x+x^2+x^3+\cdots\right)$, $x^b$ from the second, $x^c$ from the third, and $x^d$ from the fourth. Therefore, we need to count how many ways we can choose $a,b,c,d\ge0$ so that $a+b+c+d=n$ to count how many terms we get whose product is $x^n$.
To do this, we can use Stars and Bars ($3$ bars and $n$ stars).

Binomial Theorem
$$
\begin{align}
\left(1+x+x^2+x^3+\cdots\right)^4
&=(1-x)^{-4}\\
&=\sum_{n=0}^\infty\binom{-4}{n}(-x)^n\\
&=\sum_{n=0}^\infty\binom{n+3}{3}x^n\\
\end{align}
$$
since $\binom{-4}{n}=(-1)^n\binom{n+3}{n}=(-1)^n\binom{n+3}{3}$ as shown in this answer.
