%I #8 Apr 12 2021 01:36:41
%S 0,1,4,2,4,13,11,13,7,5,7,13,11,13,40,38,40,34,32,34,40,38,40,22,20,
%T 22,16,14,16,22,20,22,40,38,40,34,32,34,40,38,40,121,119,121,115,113,
%U 115,121,119,121,103,101,103,97,95,97,103,101,103,121,119,121
%N a(n) is the least k >= 0 such that A343316(n, k) = n.
%C To compute a(n): in the balanced ternary representation of n, replace each nonzero digit by "+1" and each nonleading zero by "-1".
%H Rémy Sigrist, <a href="/A343317/b343317.txt">Table of n, a(n) for n = 0..6561</a>
%e The first terms, alongside their balanced ternary representation (with "T" instead of digits "-1"), are:
%e n a(n) bter(n) bter(a(n))
%e -- ---- ------- ----------
%e 0 0 0 0
%e 1 1 1 1
%e 2 4 1T 11
%e 3 2 10 1T
%e 4 4 11 11
%e 5 13 1TT 111
%e 6 11 1T0 11T
%e 7 13 1T1 111
%e 8 7 10T 1T1
%e 9 5 100 1TT
%e 10 7 101 1T1
%e 11 13 11T 111
%e 12 11 110 11T
%e 13 13 111 111
%e 14 40 1TTT 1111
%e 15 38 1TT0 111T
%o (PARI) a(n) = if (n==0, 0, my (d=centerlift(Mod(n, 3))); if (d, +1, -1) + 3*a((n-d)\3))
%Y Cf. A343316, A343231.
%K nonn,base
%O 0,3
%A _Rémy Sigrist_, Apr 11 2021