Does there exist a function which equals $0$ for odd inputs and $1$ for even inputs? Suppose $f(n)$ is a function that equals $0$ for odd inputs of $n$ and $1$ for even inputs. Note that $n$ can only be an integer. Is there a way of explicitly defining $f(n)$ so that satisfy the above conditions, without having to use a piecewise function?

Let $$f(n)=\frac{1+\cos n\pi}2$$
