General formula for nth element of the sequence 0, 1, 0, 1, ...

$a_n=(1/2)(1+(-1)^{n+1})$, $n=0,1,2,.....$


The expression for the $n$th element of that sequence $f$ should take account of the products of $(-1)$.

As every number $n$ that appears in your sequence is just $$n = \frac{1}{2} + k,$$ where $$k = \pm\frac{1}{2},$$ then the general expression for the $n$th term $f_n$ would be the sum of the term $k$ to the $n$th: $$f_n = \frac{1}{2} + (-1)^n \left(\frac{1}{2}\right).$$

Considering that your sequence starts with the value $0$ in the first term. $(-1)^1 = -1, (-1)^2 = 1$, and so on.


Consider whether you can adjust the sequences from either of:

  • $(-1)^n$
  • $\cos(\pi n)$

to get what you are looking for, for example by adding a constant and/or multiplying by a constant