What is the formula of the real function $f$ that satisfies
\begin{equation} \sum^{n}_{k=0}{f}=1+0+(-1)+0+1+0+(-1)+0+\cdots \end{equation}
or \begin{equation} \sum^{n}_{k=0}{f}=0+1+0+(-1)+0+1+0+(-1)+\cdots \end{equation} I found here : Does there exist a function which equals $0$ for odd inputs and $1$ for even inputs? a real function that equals $0$ for odd inputs of $k$ and $1$ for even inputs.
I need the first summation. The second summation comes from the first.
Adjust the frequency and amplitude of a sine or cosine function. $$\cos(\pi n/2)$$