<s>[INST] Write the general term of the periodic sequence $1$, $-1$, $-1$, $1$, $-1$, $-1$, $1$, ..., as $(-1)^{g(n)}$ or other closed form How to put mathematically sequence that changes sign like:
$n = 0\quad f = 1$
$n = 1 \quad f = -1$
$n = 2 \quad f = -1$
$n = 3 \quad f = 1$
$n = 4 \quad f = -1$
$n = 5 \quad f = -1$
$n = 6 \quad f = 1$
.....
In the form of (-1)^(something) or similar analytical expression.
 [/INST] A meta-answer: if you already have the sequence $0,1,1,0,1,1\ldots$, then you may take the power of $-1,$ but you actually don't need exponentiation at all (similarly for other periodical sequences):
\begin{align}
a_n &=1 - 2(n^2 \bmod 3)\\
&=1 - 2n^2 + 6\lfloor n^2/3\rfloor\\
&=1 - 2\cdot \lvert (n-1) {\bmod} 3 -1\rvert\\
&= 1 - 2(\lceil n/3 \rceil - \lfloor n/3 \rfloor) \\
&= 1- 2\cdot \mathbf{1}_{\{n: \, 3\not\mid n\}}\\
&=\ldots
\end{align}
which I think is neater. Also:
$$
a_n= (-1)^{2k+1 \bmod 3}
$$
</s>