<s>[INST] 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?
 [/INST] 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!
</s>