login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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).
Appears to be A307672(n) mod 3. - Peter Munn, Aug 22 2021
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:
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
Sequence in context: A141581 A179286 A193690 * A036581 A369462 A135055
KEYWORD
nonn,base
AUTHOR
Bill Gosper, Jul 22 2005
EXTENSIONS
More terms from Alois P. Heinz, May 11 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 8 01:04 EDT 2024. Contains 375018 sequences. (Running on oeis4.)