%I #3 Nov 25 2018 14:26:17
%S 2,1,0,2,0,1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,
%T 0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,0,
%U 1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,1,0,2,0,1,2,1,0,2,0,1,2,0,1,2,1,0
%N Sequence generated by: a(3*n) = 1, a(3*n+2) = 1 - a(3*n+1), a(9*n+1) = 1, a(9*n+7) = 0, a(9*n+4) = 1 - a(3*n+1), for n >= 0.
%F FORMULA FOR TERMS: for n >= 0,
%F (1) a(3*n) = 2,
%F (2) a(3*n+2) = 1 - a(3*n+1),
%F (3) a(9*n+1) = 1,
%F (4) a(9*n+7) = 0,
%F (5) a(9*n+4) = 1 - a(3*n+1).
%o (PARI) /* Using formula for terms */
%o {a(n) =
%o if(n%3==0, 2,
%o if(n%3==2, 1 - a(n-1),
%o if(n%9==1, 1,
%o if(n%9==7, 0,
%o if(n%9==4, 1 - a((n-1)/3) )))))}
%o for(n=0, 200, print1(a(n), ", "))
%K nonn
%O 0,1
%A _Paul D. Hanna_, Nov 25 2018