OFFSET
0,3
COMMENTS
This sequence and A036581 are squarefree (they do not contain any substring XX).
Appears to be A307672(n) mod 3. - Peter Munn, Aug 22 2021
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..10000
EXAMPLE
1="1", so a(1)=1; 2=3-1="1,-1", so a(2)=2; 3=3="1,0", so a(3)=1; 4=3+1="1,1", so a(4)=0; ...
MAPLE
a:= proc(n) local d, i, m, l; m:=n; l:=[];
for i from 0 while m>0 do
d:= irem(m, 3, 'm');
if d=2 then m:=m+1; d:=-1 fi;
if d<>0 then l:=[d, l[]] fi
od;
add(l[i]*(-1)^(i-1), i=1..nops(l)) mod 3
end:
seq(a(n), n=0..105); # Alois P. Heinz, May 11 2015
MATHEMATICA
a[n_] := Module[{d, i, m = n, l = {}}, For[i = 0, m>0, i++, d = Mod[m, 3]; m = Quotient[m, 3]; If[d==2, m++; d = -1]; If[d != 0, l = Prepend[l, d]]]; Mod[Sum[l[[i]] (-1)^(i-1), {i, 1, Length[l]}], 3]];
a /@ Range[0, 105] (* Jean-François Alcover, Nov 18 2020, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bill Gosper, Jul 22 2005
EXTENSIONS
More terms from Alois P. Heinz, May 11 2015
STATUS
approved