I am now aware of periodic functions, and how they cycle like binary flags. It helps to use this in discrete math.
This brings me to my problem. I am trying to make a function that is periodic for cycles more than two. I have been using $asin^2(z\pi/2) + bcos^2(z\pi/2)$ for cycles of legnth two, and can't seem to alternate them in sets of three with 0's in between. To be more specific, it will give a particular value once every three integers and another particular value in the other cases. In the case with periodic size two it would give the value $a$ and $b$ alternately. However instead I need something along the lines of, if x is an integer $f(x) = 4$ for every $n$th term and $f(x) = 0$ for the others. For $n=3$ the cycle would go $4, 0, 0, 4, 0, 0, \dots$
-TJL
Is there any reason not to definying the function in the following way $$ f(x)=\begin{cases} 4 \text{ if $x=3k$, $k\in\mathbb{N}$}\\ 0 \text{ elsewhere}. \end{cases}\quad? $$
Edit: A new version for the expected continuous case.
Consider the function $$ f(x)=\begin{cases} 4-4x& \text{ for $0\leq x\leq1$}\\ 0 &\text{ for $1\leq x\leq2$}\\ 4x-8 &\text{ for $2\leq x\leq3$}. \end{cases} $$ This function, repeated in the obvious way, is continuous and has the desired property. As far as I understand your future applications, its approximation by its Fourier series will be useful for you.