How to calculate the Nth member of this Generating function? The series 012012012... matches the following generating function:
$$T=\frac{x+2x^2}{1-x^3}$$
How could i find a closed expression of the nth member of this series?
 A: For a bloated answer:
\begin{align*}
  T &= \frac{x+2x^2}{1-x^3} \\
  &= \frac{1}{1-x}+\frac{\frac{1}{2}-\frac{\sqrt{3}}{6}\, i}{-\frac{1}{2}+\frac{\sqrt3}{2}\, i - x}-\frac{\frac{1}{2}+\frac{\sqrt{3}}{6}\, i}{\frac{1}{2}+\frac{\sqrt3}{2}\, i + x} 
\end{align*}
Extracting $[x^n]$ now gives:
\begin{align*}
  a_n &= 1+\frac{\displaystyle \frac{1}{2}-\frac{\sqrt{3}}{6}\, i}{\displaystyle \left(-\frac{1}{2}+\frac{\sqrt3}{2}\, i\right)^{n+1}}- (-1)^n \frac{\displaystyle \frac{1}{2}+\frac{\sqrt{3}}{6}\, i}{\displaystyle \left(\frac{1}{2}+\frac{\sqrt3}{2}\, i\right)^{n+1}}
\end{align*}
Update
Thanks everyone for the discussion and answers!
Using Qiaochu Yuan's answer and notation, we can get the partial fraction, 
and in turn, the formula.
For any period $0,1,\ldots, k$, the generating function is:
$$G(x) = \frac{P(x)}{Q(x)}$$
where 
\begin{align*}
  P(x) &= \sum_{u=1}^k u\, x^u \\
  Q(x) &= 1-x^{k+1}
\end{align*}
and the general term is:
\begin{align*}
  a_n &= \sum_{v=0}^k \frac{P\left(\zeta^v\right)}{Q'\left(\zeta^v\right)\, \zeta^{v\, (n+1)}}
\end{align*}
where $\zeta=e^{2\pi\, i\, /(k+1)},\;\; i=\sqrt{-1}$
Simplification is looking difficult now!
A: @Ido4848
Inspired by the way my old TI-92 would represent periodic sequences and Claude's answer we can get
$$A_n=1-\left(\frac{\sin  (\frac{2 \pi  n}{3})}{\sqrt{3}}+ \cos  \left (\frac{2 \pi n}{3}  \right )\right)$$ 
for the nth term.
A: $$
T=\frac{x+2x^2}{1-x^3} = (x+2x^2)\sum_{n=0}^{\infty} x^{3n} = \sum_{n=0}^{\infty}x^{3n+1}+2x^{3n+2}
$$

So, coefficients of powers that are multiples of 3 =0
coefficients of powers that are one more than multiples of 3 = 1
coefficients of powers that are two more than multiples of 3 = 2

A: In what you wrote, you could see that $$a_n=n-3 \left\lfloor \frac{n}{3}\right\rfloor$$
