Suppose we have the following sequence:
{$a_n$} such as:
$a_0 = 1, \\
a_1 = 1, \\
a_2 = -1, \\
a_3 = -1, \\
a_4 = 1, \\
a_5 = 1, \\
...
$
How can we find the general term of this sequence? I tried using a trigonometric function e.g. $\alpha \sin(x+\phi)$, then we impose some constraints on $\alpha$ and $\phi$ to get that sequence, but I get lost, is there any clever way to find the general term?
EDIT: The question is identified as duplicate, but that answer does not solve the question, because I am looking for a solution that does not involve floor function.
You could use $\cos(n\pi/2)+\sin(n\pi/2)$. I see this working by thinking about the unit circle. A needle pointing East, North, West, or South always contributes a $0$ from among $\cos(n\pi/2),\sin(n\pi/2)$ and also either $1$ or $-1$. And it just works out.
Trig identities show this is equal to to $\sqrt{2}\sin(n\pi/2+\pi/4)$
Or from a different perspective, $(-1)^{n(n-1)/2}$. The expression $n(n-1)$ is always even, so always divisible by $2$. Sometimes, one of $n,n-1$ is also divisible by $4$, so that you still have an even number after dividing by $2$. As $n$ iterates, first $n$ will be divisible by $4$, then $n-1$ will be divisible by $4$, then $n$ will be divisible only by $2$, then $n-1$ will be divisible only by $2$. And then it all repeats. So the exponent on $(-1)$ is even, even, odd, odd, repeat.