How can I get sequence $4,4,2,4,4,2,4,4,2\ldots$ into equation? How can I write an equation that expresses the nth term of the sequence:
$$4, 4, 2, 4, 4, 2, 4, 4, 2, 4, 4, 2,\ldots$$

$$4-2\cdot\mathbf 1_{3\mid n}\qquad\text{or}\qquad 2+2\cdot\mathbf 1_{\gcd(3,n)=1}$$
