What's the simplest way to write a function that outputs the sequence:

```
{1, 0, -1, 0, 1, 0, -1, 0, ...}
```

... without using any trig functions?

I was able to come up with a very complex sequence involving -1 to some complicated formula, but I was hoping there is a more simple solution.

$n$ should start at 0 and go to infinity.

**Update:**

All the solutions you guys provided are great! I wasn't aware there were so many of them. I should have mentioned that I prefer a solution which doesn't use recursion; imaginary numbers; matrices; functions with `if`

statements; or functions such as `ceil`

, `floor`

, or `mod`

. I'm looking for something using basic algebra: addition/subtraction, multiplication/division, exponents, etc. However, I will accept anything since I didn't include this clause originally.

This is what I came up with:

$$a_n=\frac{\left(-1\right)^n+1}{2}\cdot \left(-1\right)^{\left(\frac{n}{2}-\frac{\left(-1\right)^{n+1}+1}{4}\right)}$$

Is there a less complicated way (i.e. fewer terms) to get this same sequence?