%I #12 Apr 09 2021 11:55:23
%S 0,1,3,2,3,7,6,7,5,4,5,7,6,7,15,14,15,13,12,13,15,14,15,11,10,11,9,8,
%T 9,11,10,11,15,14,15,13,12,13,15,14,15,31,30,31,29,28,29,31,30,31,27,
%U 26,27,25,24,25,27,26,27,31,30,31,29,28,29,31,30,31,23
%N A binary encoding of the nonzero digits in balanced ternary representation of n.
%C The ones in the binary representation of a(n) correspond to the nonzero digits in the balanced ternary representation of n.
%C We can extend this sequence to negative indices: a(-n) = a(n) for any n >= 0.
%H Rémy Sigrist, <a href="/A343231/b343231.txt">Table of n, a(n) for n = 0..6561</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>
%F a(n) = A343228(n) + A343229(n).
%e The first terms, alongside the balanced ternary representation of n (with "T" instead of digits "-1") and the binary representation of a(n), are:
%e n a(n) ter(n) bin(a(n))
%e -- ---- ------ ---------
%e 0 0 0 0
%e 1 1 1 1
%e 2 3 1T 11
%e 3 2 10 10
%e 4 3 11 11
%e 5 7 1TT 111
%e 6 6 1T0 110
%e 7 7 1T1 111
%e 8 5 10T 101
%e 9 4 100 100
%e 10 5 101 101
%e 11 7 11T 111
%e 12 6 110 110
%e 13 7 111 111
%e 14 15 1TTT 1111
%e 15 14 1TT0 1110
%o (PARI) a(n) = { my (v=0, b=1, t); while (n, t=centerlift(Mod(n, 3)); if (t, v+=b); n=(n-t)\3; b*=2); v }
%Y Cf. A059095, A140267, A289831, A343228, A343229, A343230.
%K nonn,look,base
%O 0,3
%A _Rémy Sigrist_, Apr 08 2021