OFFSET
0,3
COMMENTS
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.
Can extend to negative n by a(-n) = -a(n).
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.
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).
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.
LINKS
EXAMPLE
n = 224 = balanced ternary 1, 0, -1, 1, 0, -1
reverse ^^^^^^^^^^^^^^^^
a(n) = 168 = balanced ternary 1, -1, 0, 1, -1, 0
PROG
(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));
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Kevin Ryde, Feb 19 2022
STATUS
approved