[go: up one dir, main page]

login
A351702
In the balanced ternary representation of n, reverse the order of digits other than the most significant.
4
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, 18, 27, 36, 21, 30, 39, 16, 25, 34, 19, 28, 37, 22, 31, 40, 41, 68, 95, 50, 77, 104, 59, 86, 113, 44, 71, 98, 53, 80, 107, 62, 89, 116, 47, 74, 101, 56, 83, 110, 65, 92
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.
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
Cf. A059095 (balanced ternary), A134028 (full reverse), A134027 (palindromes).
In other bases: A059893 (binary), A343150 (Zeckendorf), A343152 (lazy Fibonacci).
Sequence in context: A211981 A019997 A263875 * A125157 A093327 A361971
KEYWORD
nonn,base,easy
AUTHOR
Kevin Ryde, Feb 19 2022
STATUS
approved