Finding a formula for a repeating sequence of 1's and -1's Is there a simple formula for the sequence $(a_n)$ given by $(1,1,-1,1,1,-1,1,1,-1,\cdots)$ 
(with the repeating pattern 1,1,-1), starting with $n=1$?
 A: $$a_n=\frac{1-2\,\mathrm j^n-2\,\mathrm j^{2n}}3\quad\text{where}\quad \mathrm j=\frac{-1+\mathrm i\,\sqrt3}2=\mathrm e^{2\mathrm i\pi/3}$$
More generally, every sequence $(\alpha_n)_{n\geqslant3}$ of period $3$ can be written as
$$
\alpha_n=A+B\,\mathrm j^n+C\,\mathrm j^{2n},
$$
for some well chosen $(A,B,C)$, because $\{1,\mathrm j,\mathrm j^2\}$ are the three solutions of the equation $z^3=1$.
A: If $p(x) = \frac{1}{2}x (x-1)$, then $a_n = 1-2p(n \mod 3)$.
Here is nicer one (assuming that $n$ starts from $1$):
Let $a_n = 1-2\left( \frac{\cos(2 \pi \frac{n}{3})+1}{3} \right)$
A: $${ \left( -1 \right)  }^{ (n+1)\mod 3  }$$ where $n$ starts from $1$. 
Or
$${ \left( -1 \right)  }^{ (n+2 ){ \mod 3 }  }$$ where $n$ starts from $0$. 
A: $$\frac{1-4\cos\left(2\pi\cdot\frac{n+1}3\right)}3$$
A: Starting with $n=0$ : $$2\cdot|(n+2)\bmod 3-1|-1$$
Starting with $n=1$ : $$2\cdot(n^2 \bmod 3)-1$$
A: $$2\left(3\left\lfloor{n+1\over3}\right\rfloor-n\right)^2-1$$
Added later:  Inspired by CODE's nice answer, here's another, simpler formula along the same lines:
$$-1-2\left(\left\lfloor {n\over3}\right\rfloor+ \left\lfloor {-n\over3}\right\rfloor\right)$$
A: $(-1)^{[\frac{n}{3}]+[\frac{-n}{3}]+1}$
A: $a_{n+1} = (-1)\frac{a_n}{a_{n-1}} \, a_1=1,a_2=1$
or
$a_{n+1} = (-1)a_na_{n-1} \,\,, a_1=1,a_2=1$
This theme can be used to generate other sequences like $1,1,1,-1,1,1,1,-1,...$:
$b_{n+2} = (-1)b_{n-1}b_{n}b_{n+1} \,\,, b_1=1,b_2=1,b_3=1$
A: A recursive expression:
$$ a_1 = 1\\ a_2=1 \\ a_{k+2}=-a_{k+1} \cdot a_k $$
