|
|
A108964
|
|
Write n in balanced ternary notation, omit any zeros and form the left-to-right alternating sum mod 3.
|
|
1
|
|
|
0, 1, 2, 1, 0, 1, 2, 0, 2, 1, 0, 2, 0, 1, 2, 1, 0, 1, 2, 0, 1, 0, 2, 1, 2, 0, 2, 1, 0, 2, 0, 1, 0, 2, 1, 2, 0, 1, 2, 1, 0, 1, 2, 0, 2, 1, 0, 2, 0, 1, 2, 1, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 1, 0, 2, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 1, 2, 0, 2, 1, 0, 2, 0, 1, 0, 2, 1, 2, 0, 1, 2, 1, 0, 2, 0, 1, 0, 2, 1, 0, 1, 2, 0, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
This sequence and A036581 are squarefree (they do not contain any substring XX).
|
|
LINKS
|
|
|
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:
|
|
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]];
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|