Look at this sequence:
$$a_n=\left\{1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, 1, 0, 0, 2, \cdots \right\}$$
This is a periodic sequence. Repeating block is $\left\{1, 0, 0, 2\right\}.$
Here is my closed form:
$$a_n = \frac 14((-1)^n + (2 + i) (-i)^n + (2 - i) i^n + 3)$$
where, $i^2=-1$
Is it possible to find a closed form using modular arithmetic?
I mean for example,
$A\mod 3+B\mod 4 \cdots \cdots \cdots$
Is it possible?
You want a function of $n$ that behaves as follows:
$f(n) = \begin{cases} 1 \text{ if } n \mod 4 = 1\\ 0 \text{ if } n \mod 4 = 2,3\\ 2 \text{ if } n \mod 4 = 0\end{cases}$
Let's denote $n \mod 4$ by $n'$. The polynomial $n'(n'-2)(n'-3)$ is $0$ when $n'=0,2,3$ and takes the value $2$ when $n'=1$. So this suggests
$\frac 1 2 n'(n'-2)(n'-3)$
should be part of a closed form expression. Similarly $(n'-1)(n'-2)(n'-3)$ is $0$ when $n'=1,2,3$ and takes the value $-6$ when $n'=0$. So this suggests
$-\frac 1 3 (n'-1)(n'-2)(n'-3)$
should be part of the expression too. So we have
$f(n) = \frac 1 2 n'(n'-2)(n'-3) - \frac 1 3 (n'-1)(n'-2)(n'-3)\\ = \frac 1 6 (n'+2)(n'-2)(n'-3) \\ = \frac 1 6 (n'^3 -3n'^2 -4n'+12) \text{ where } n'=n\mod 4$