Formula for periodic sequence $1, 3, 2, -1, -3, -2, \ldots$ I‘m trying to figure out a formula for the periodic sequence 1, 3, 2, -1, -3, -2,…
The numbers repeat after that.
So I want to write down, that if I have the series $(a_k)$ that $a_1=a_7=…$ etc. until $a_6=a_{12}=…$ etc. as simple as possible.
In our solution book it‘s written $a_n=a_{n+6k}$ which doesn‘t make any sense for me. That would mean, if I want to calculate $a_{100}=a_{100+6k}$?
I came up with another, but not elegant solution, that I would write down all the six possible numbers with added part that looks like „if n = 1 (mod 6)“ etc.
But is there a simpler way to express this series if I have to calculate $a_{1000}$ for example?
 A: The n-th term, starting at n=1, is given by the residue mod $7$
of $3^{n-1},$ with the proviso that one writes $-1$ for $6,$ $-3$ for $4$, and $-2$ for $5.$ [I've heard of this as the "numerically least residue".]
A: You can just write $a_n=a_{[n]}$ where $[n]$ is the class of $n$ modulo $6$.
An alternative way of writing this is writing explicitly the module:
$n \ mod \ 6 = n- 6 \cdot \lfloor{\frac{n}{6}}\rfloor$, so:
$$a_n=a_{n- 6 \cdot \lfloor{\frac{n}{6}}\rfloor}$$
A: Any periodic sequence has a "Fourier series", analogous to the Fourier series for a periodic function.
For an integer $N>0$ let $$\omega_N=e^{2\pi i/N}.$$


Lemma. If $k$ is an integer then $\sum_{n=1}^N\omega_N^{kn}=\begin{cases}N,&(N|n),
\\0,&(N\not |n).\end{cases}$


Hint: this is a geometric series. Or look up "roots of unity" somewhere.


Theorem. If $(a_n)$ is a sequence of period $N$ (that is, $a_{n+N}=a_n$) then there exist $c_0,\dots,c_{N-1}$ such that $a_n=\sum_{k=0}^{N-1}c_k\omega_N^{nk}.$ The coefficients are given by $c_k=\frac1N\sum_{j=0}^{N-1}a_j\omega_N^{n(j-k)}.$


Hint: "orthonormal basis" (for the space of $N$-periodic sequences with the obvious inner product).
