OFFSET
0,3
COMMENTS
This sequence can naturally be extended to negative integers; we then obtain a permutation of the integers (Z).
A number is a fixed point of this sequence iff it has no digit -1 in its balanced ternary expansion (A005836).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..6561
FORMULA
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 -4 1T TT
3 3 10 10
4 4 11 11
5 11 1TT 11T
6 -12 1T0 TT0
7 -11 1T1 TT1
8 -10 10T T0T
9 9 100 100
10 10 101 101
11 -13 11T TTT
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);
forstep (k=#d, 1, -1, if (d[k], d[k]=p*=d[k]));
fromdigits(d, 3);
}
CROSSREFS
KEYWORD
sign,base
AUTHOR
Rémy Sigrist, May 08 2022
STATUS
approved