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.
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
Examples
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
Links
Programs
-
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); }
Formula
a(3*n) = 3*a(n).
Comments