login
A353828
The positions of nonzero digits in the balanced ternary expansions of n and a(n) are the same, and the k-th leftmost nonzero digit in a(n) equals the product of the k leftmost nonzero digits in n.
5
0, 1, 2, 3, 4, 7, 6, 5, 8, 9, 10, 11, 12, 13, 20, 21, 22, 19, 18, 17, 16, 15, 14, 25, 24, 23, 26, 27, 28, 29, 30, 31, 34, 33, 32, 35, 36, 37, 38, 39, 40, 61, 60, 59, 62, 63, 64, 65, 66, 67, 56, 57, 58, 55, 54, 53, 52, 51, 50, 47, 48, 49, 46, 45, 44, 43, 42, 41
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.
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
See A305458, A353824, A353826, A353830 for similar sequences.
Cf. A353829 (inverse).
Sequence in context: A072275 A122989 A222246 * A321726 A353829 A267299
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, May 08 2022
STATUS
approved