Formula for a repeating sequence of 5 integers Consider a repeating sequence of 5 integers...
$$\begin{array}{rrrrrrrrrrr}
n:&      1,& 2,& 3,& 4,& 5,& 6,& 7,& 8,& 9,& 10,& ...\\
f(n):&  -2,& 1,& 0,& -1,& 2,& -2,& 1,& 0,& -1,& 2,&  ...
\end{array}
$$
I need a function that generates these sequence values.  eg: $f(6) = -2$
If there were only $3$ repeating integers  (say $-2, 1, 0, -2, 1, 0$...), I could solve for $A$, $B$, and $C$ in 
$$\begin{align}
f(1) =   A  + \sin(1\times2\pi/3)*B  +  \cos(1\times2\pi/3)*C  &=  -2\\
f(2) =   A  + \sin(2\times2\pi/3)*B  +  \cos(2\times2\pi/3)*C  &=   1\\
f(3) =   A  + \sin(3\times2\pi/3)*B  +  \cos(3\times2\pi/3)*C  &=   0
\end{align} $$
But, with $5$ repeating integers, I'm having trouble setting up the $5$ equations.  I would use the coefficients  $\sin(n\times 2\pi/5)$ and $\cos(n\times 2\pi/5))$, but I suspect each function needs $5$ terms (in $A$, $B$, $C$, $D$, and $E$).  Any clues how to set this up?
 A: How about 
$$
f(n) = (((n-1) \bmod 5) - 2) \, (-1)^{((n-1) \bmod 5) \bmod 2}
$$
Which means shift the argument by one, then going into a modulo 5 cycle, shifting the values by $-2$. Modulating the whole with with those funny minus signs for the positions $1$ and $3$ (in contrast to $0$, $2$, $4$).
I told my friend Ruby about it
def f(n)
  k = (n-1) % 5
  (k-2) * (-1)**(k % 2)
end

(1..20).each do |k|
  puts "#{k}: #{f(k)}"
end

and she replied with:
1: -2
2: 1
3: 0
4: -1
5: 2
6: -2
7: 1
8: 0
9: -1
10: 2
11: -2
12: 1
13: 0
14: -1
15: 2
16: -2
17: 1
18: 0
19: -1
20: 2

A: I would use
$$
f(n)=g(n\ \text{mod } 5)
$$
where $g:\{0,1,2,3,4\}\to\{-2,-1,0,1,2\}$ with
$$
g(1)-2,\ g(2)=1, g(3)=0, g(4)=-1,g(0)=2.
$$
A: Try including $\sin(n\times4\pi/5)$ and $\cos(n\times4\pi/5)$.  These are the upcoming terms in the Fourier series.
Solving the system we then get
$$f(x) = 0 -0.145\sin\left(\frac{2\pi}{5}x\right)+0.106\cos\left(\frac{2\pi}{5}x\right)-0.616\sin\left(\frac{4\pi}{5}x\right)+1.894\cos\left(\frac{4\pi}{5}x\right)$$
Or approximately.  I haven't found nice closed form solutions for the coefficients; they may yet exist but I don't know what they are.  (I do know that the paired coefficients for each frequency give a sine wave with a zero point at $x=3$ but that's all I've got)
Here that is, plotted.

A: If you allow yourself the floor function then
$$
f(n) = (-1)^{n+1 - 5 \lfloor (n/5 \rfloor} \left( n - 3 - 5\left\lfloor \frac{n-1}{5} \right\rfloor \right)
$$
does the job.
