I'm having trouble finding a generating function for the sequence that has a closed form. The sequence can be deduced using two powers, with alternating negative and multiples of three as shown:
first term: $1=1$
second term: $2=1+2^{0}$
third term: $4=1+2^{0}+2^{1}$
fourth term: $0=1+2^{0}+2^{1}-2^{2}$
...
n-th term: $n = 1+2^{0}+2^{1}-2^{2}+2^{3}+2^{4}+3(2^{5})+2^{6}+2^{7}-2^{8}+...$
Therefore, the -1 appears at every $4(mod6)$ term and the 3 appears at every $1(mod6)$ term greater than 1.
So I can construct the n-th ($n>1$) term as follows:
$f(n) = 1+\sum_{i=2}^{n}2^{i-2}u(i)$
where
$u(i)=-1$, if $i\equiv4(mod6)$
$u(i)=3$, if $i\equiv1(mod6)$
$u(i)=1$, otherwise
Is there a way to get a closed form of the function $f(n)$?
$f(n)=2^{n-1}-2^{\lfloor\frac {n}6\rfloor+5}+2^{6\lfloor\frac {n+3}6\rfloor+2},$ which only works for $n\ge 7$.