This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A108964 #16 Sep 03 2021 14:06:49 %S A108964 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, %T A108964 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, %U A108964 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 %N A108964 Write n in balanced ternary notation, omit any zeros and form the left-to-right alternating sum mod 3. %C A108964 This sequence and A036581 are squarefree (they do not contain any substring XX). %C A108964 Appears to be A307672(n) mod 3. - _Peter Munn_, Aug 22 2021 %H A108964 Alois P. Heinz, <a href="/A108964/b108964.txt">Table of n, a(n) for n = 0..10000</a> %e A108964 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; ... %p A108964 a:= proc(n) local d, i, m, l; m:=n; l:=[]; %p A108964 for i from 0 while m>0 do %p A108964 d:= irem(m, 3, 'm'); %p A108964 if d=2 then m:=m+1; d:=-1 fi; %p A108964 if d<>0 then l:=[d, l[]] fi %p A108964 od; %p A108964 add(l[i]*(-1)^(i-1), i=1..nops(l)) mod 3 %p A108964 end: %p A108964 seq(a(n), n=0..105); # _Alois P. Heinz_, May 11 2015 %t A108964 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]]; %t A108964 a /@ Range[0, 105] (* _Jean-François Alcover_, Nov 18 2020, after _Alois P. Heinz_ *) %Y A108964 Cf. A036581, A307672. %K A108964 nonn,base %O A108964 0,3 %A A108964 _Bill Gosper_, Jul 22 2005 %E A108964 More terms from _Alois P. Heinz_, May 11 2015