How is $\frac{x}{(1-x)^2}$ the equation for the sequence $0, 1, 2, 3, 4,\dots$ Our prof said this for a homework question:

I get that the function shown in a is $0, 0, 0, 0, 0, 0, 1, 2, 3, 4...$
But how is $\dfrac{x}{(1-x)^2}$ the sequence $0, 1, 2, 3, 4, ...$?
For the $0$th term, we'd have $0/1$, which is $0$. Good. For the first we'd have $1/0$, which is infinite. Not so good. For the second we'd have $2$, okay. For the third, $3/4$, um, not quite. Our sequence is $0$, infinite, $2$, $3/4$, so far. A far cry from $0, 1, 2, 3, 4,\dots$
Could someone explain this to me?
 A: You’re confusing the values of the generating function $g(x)$ at $x=0,1,2,\dots$ with the sequence whose generating function it is. If $g(x)$ is the generating function for a sequence $\langle a_0,a_1,a_2,\dots\rangle$, it is not generally the case that $g(n)=a_n$. When we say that $g(x)$ is the generating function of the sequence $\langle a_0,a_1,a_2,\dots\rangle$, we mean that
$$g(x)=\sum_{n\ge 0}a_nx^n\;.$$
In other words, the $n$th term of the sequence is the coefficient of $x^n$ in the power series expansion of $g(x)$.
In this case the starting point is the sequence $\langle 1,1,1,\dots\rangle$ and its generating function
$$\frac1{1-x}=\sum_{n\ge 0}x^n=1+x+x^2+x^3+\ldots~\;.\tag{1}$$
Note that plugging $x=0,1,2,\dots$ into $f$ does not give you the constant $1$ sequence: that’s the sequence of coefficients in the power series. 
Now differentiate $(1)$ to get
$$\frac1{(1-x)^2}=\sum_{n\ge 0}nx^{n-1}=1+2x+3x^2+\ldots\;.$$
Now multiply both sides by $x$ to get
$$\frac{x}{(1-x)^2}=\sum_{n\ge 0}nx^n=0+x+2x^2+3x^3+\ldots\;,$$
whose coefficients yield the sequence $\langle 0,1,2,3,\dots\rangle$, exactly as stated.
A: The point is that $\frac{x}{(1-x)^2} = \frac{1}{1-x}\cdot\frac{x}{1-x} = (1+x+x^2 + \ldots)(x + x^2 + \ldots),$ where the last equality is from the sum of a geometric series (converges when $|x| < 1$). Expand this out to get the desired coefficients.
Remark: I should note that expanding only works because of Merten's Theorem.
