A379658 The balanced ternary expansion of a(n) is obtained by removing a digit 0 before each nonzero digit in the nonadjacent form of n.
0, 1, 3, 2, 9, 4, 6, 8, 27, 10, 12, 5, 18, 7, 24, 26, 81, 28, 30, 11, 36, 13, 15, 17, 54, 19, 21, 23, 72, 25, 78, 80, 243, 82, 84, 29, 90, 31, 33, 35, 108, 37, 39, 14, 45, 16, 51, 53, 162, 55, 57, 20, 63, 22, 69, 71, 216, 73, 75, 77, 234, 79, 240, 242, 729
Offset: 0
Examples
The first terms are: n a(n) naf(n) bter(a(n)) -- ---- ------ ---------- 0 0 0 0 1 1 1 1 2 3 10 10 3 2 10T 1T 4 9 100 100 5 4 101 11 6 6 10T0 1T0 7 8 100T 10T 8 27 1000 1000 9 10 1001 101 10 12 1010 110 11 5 10T0T 1TT 12 18 10T00 1T00
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..10000
- Joerg Arndt, Matters Computational (The Fxtbook), pages 61-62.
- Wikipedia, Balanced ternary
- Wikipedia, Non-adjacent form
- Index entries for sequences that are permutations of the natural numbers
Programs
-
PARI
a(n) = { my (v = 0, t = 1, d); while (n, if (n%2, n -= d = 2 - (n%4); v += d*t; t /= 3;); n \= 2; t *= 3;); return (v); }
Comments