OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative integers with inverse A353829.
A number is a fixed point of this sequence iff it has at most one digit -1 in its balanced ternary expansion, that digit -1 being its rightmost nonzero digit.
LINKS
FORMULA
a(3*n) = 3*a(n).
EXAMPLE
The first terms, in decimal and in balanced ternary, are:
n a(n) bter(n) bter(a(n))
-- ---- ------- ----------
0 0 0 0
1 1 1 1
2 2 1T 1T
3 3 10 10
4 4 11 11
5 7 1TT 1T1
6 6 1T0 1T0
7 5 1T1 1TT
8 8 10T 10T
9 9 100 100
10 10 101 101
11 11 11T 11T
12 12 110 110
PROG
(PARI) a(n) = {
my (d=[], t, p=1);
while (n, d=concat(t=[0, 1, -1][1+n%3], d); n=(n-t)/3);
for (k=1, #d, if (d[k], d[k]=p*=d[k]));
fromdigits(d, 3);
}
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, May 08 2022
STATUS
approved