Formula for a periodic sequence of 1s and -1s with period 5
We have $$ \frac{4\cos\left(\frac{2\pi k}5\right)+4\cos\left(\frac{4\pi k}5\right)-3}5= \left\{\begin{array}{} -1&\text{if }k\not\equiv0\pmod5\\ +1&\text{if }k\equiv0\pmod5\\ \end{array}\right.\tag{1} $$
Explanation
The roots of $z^5-1$ are $z=e^{2\pi ik/5}$ for $k\in\{0,1,2,3,4\}$. Vieta says that the coefficient of $z^4$ in $z^5-1$ the sum of the roots of $z^5-1$. That is, the sum of the roots is $0$. Taking the real part of the roots yields $$ 1+\cos\left(\frac{2\pi}5\right)+\cos\left(\frac{4\pi}5\right)+\cos\left(\frac{6\pi}5\right)+\cos\left(\frac{8\pi}5\right)=0\tag{2} $$ When $k\not\equiv0\pmod5$, $k$ is invertible $\bmod5$. Therefore, $$ \left(\cos\left(\frac{2\pi k}5\right),\cos\left(\frac{4\pi k}5\right),\cos\left(\frac{6\pi k}5\right),\cos\left(\frac{8\pi k}5\right)\right)\tag{3} $$ is a permutation of $$ \left(\cos\left(\frac{2\pi}5\right),\cos\left(\frac{4\pi}5\right),\cos\left(\frac{6\pi}5\right),\cos\left(\frac{8\pi}5\right)\right)\tag{4} $$ Therefore, $$ 1+\cos\left(\frac{2\pi k}5\right)+\cos\left(\frac{4\pi k}5\right)+\cos\left(\frac{6\pi k}5\right)+\cos\left(\frac{8\pi k}5\right)=0\tag{5} $$ when $k\not\equiv0\pmod5$. When $k\equiv0\pmod5$, $$ 1+\cos\left(\frac{2\pi k}5\right)+\cos\left(\frac{4\pi k}5\right)+\cos\left(\frac{6\pi k}5\right)+\cos\left(\frac{8\pi k}5\right)=5\tag{6} $$ Since $\cos(x)$ is an even function with period $2\pi$, $(5)$ and $(6)$ become $$ 1+2\cos\left(\frac{2\pi k}5\right)+2\cos\left(\frac{4\pi k}5\right) =\left\{\begin{array}{} 0&\text{if }k\not\equiv0\pmod5\\ 5&\text{if }k\equiv0\pmod5\\ \end{array}\right.\tag{7} $$ Equation $(1)$ is simply a scaled and translated version of $(7)$.