%I #16 Feb 24 2022 22:53:28
%S 0,1,2,3,4,5,8,11,6,9,12,7,10,13,14,23,32,17,26,35,20,29,38,15,24,33,
%T 18,27,36,21,30,39,16,25,34,19,28,37,22,31,40,41,68,95,50,77,104,59,
%U 86,113,44,71,98,53,80,107,62,89,116,47,74,101,56,83,110,65,92
%N In the balanced ternary representation of n, reverse the order of digits other than the most significant.
%C Self-inverse permutation with swaps confined to terms of a given digit length (A134021) so within blocks n = (3^k+1)/2 .. (3^(k+1)-1)/2.
%C Can extend to negative n by a(-n) = -a(n).
%C A072998 is balanced ternary coded in decimal digits so that reversal except first digit of A072998(n) is at A072998(a(n)). Similarly its ternary equivalent A157671, and also A132141 ternary starting with 1.
%C These sequences all have a fixed initial digit followed by all ternary strings which is the reversed part. A007932 is such strings as decimal digits 1,2,3 but it omits the empty string so the whole reversal of A007932(n) is at A007932(a(n+1)-1).
%C Fixed points a(n) = n are where n in balanced ternary is a palindrome apart from its initial 1. These are the full balanced ternary palindromes with their least significant 1 removed, so all n = (A134027(m)-1)/3 for m>=2.
%H Kevin Ryde, <a href="/A351702/b351702.txt">Table of n, a(n) for n = 0..9841</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>
%e n = 224 = balanced ternary 1, 0, -1, 1, 0, -1
%e reverse ^^^^^^^^^^^^^^^^
%e a(n) = 168 = balanced ternary 1, -1, 0, 1, -1, 0
%o (PARI) a(n) = if(n==0,0, my(k=if(n,logint(n<<1,3)), s=(3^k+1)>>1); s + fromdigits(Vec(Vecrev(digits(n-s,3)),k),3));
%Y Cf. A059095 (balanced ternary), A134028 (full reverse), A134027 (palindromes).
%Y Cf. A072998, A157671, A132141, A007932.
%Y In other bases: A059893 (binary), A343150 (Zeckendorf), A343152 (lazy Fibonacci).
%K nonn,base,easy
%O 0,3
%A _Kevin Ryde_, Feb 19 2022