Finding a function that oscillates between 0 and 1 [closed]

Something like this?: $f:\mathbb{N} \to \{0, 1\}$

$$f(n) = \frac{1}{2} (1 + (-1)^n)$$

We have $(-1)^n = 1$ for all even $n$, and $(-1)^m = -1$ for all odd $m$.


For $x$ even set $f(x)=1$ and for $x$ odd set $f(x)=0$. You can do this with division modulo $2$ as well.