A353826 The positions of nonzero digits in the ternary expansions of n and a(n) are the same, and the k-th rightmost nonzero digit in a(n) equals modulo 3 the product of the k rightmost nonzero digits in n.
0, 1, 2, 3, 4, 8, 6, 7, 5, 9, 10, 20, 12, 13, 26, 24, 25, 14, 18, 19, 11, 21, 22, 17, 15, 16, 23, 27, 28, 56, 30, 31, 62, 60, 61, 32, 36, 37, 74, 39, 40, 80, 78, 79, 41, 72, 73, 38, 75, 76, 44, 42, 43, 77, 54, 55, 29, 57, 58, 35, 33, 34, 59, 63, 64, 47, 66, 67
Offset: 0
Examples
The first terms, in decimal and in ternary, are: n a(n) ter(n) ter(a(n)) -- ---- ------ --------- 0 0 0 0 1 1 1 1 2 2 2 2 3 3 10 10 4 4 11 11 5 8 12 22 6 6 20 20 7 7 21 21 8 5 22 12 9 9 100 100 10 10 101 101 11 20 102 202 12 12 110 110
Links
Programs
-
PARI
a(n) = { my (d=digits(n,3), p=1); forstep (k=#d, 1, -1, if (d[k], d[k]=p*=d[k])); fromdigits(d%3,3) }
Formula
a(3*n) = 3*a(n).
a(3*n + 1) = 3*a(n) + 1.
Comments