A379657 The nonadjacent form of a(n) is obtained by inserting a digit 0 before each nonzero digit in the balanced ternary expansion of n.
0, 1, 3, 2, 5, 11, 6, 13, 7, 4, 9, 19, 10, 21, 43, 22, 45, 23, 12, 25, 51, 26, 53, 27, 14, 29, 15, 8, 17, 35, 18, 37, 75, 38, 77, 39, 20, 41, 83, 42, 85, 171, 86, 173, 87, 44, 89, 179, 90, 181, 91, 46, 93, 47, 24, 49, 99, 50, 101, 203, 102, 205, 103, 52, 105
Offset: 0
Examples
The first terms are: n a(n) bter(n) naf(a(n)) -- ---- ------- --------- 0 0 0 0 1 1 1 1 2 3 1T 10T 3 2 10 10 4 5 11 101 5 11 1TT 10T0T 6 6 1T0 10T0 7 13 1T1 10T01 8 7 10T 100T 9 4 100 100 10 9 101 1001 11 19 11T 1010T 12 10 110 1010
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, d, b = 1); while (n, d = centerlift(Mod(n, 3)); n = (n-d)/3; v += d * b; b *= if (d, 4, 2);); v; }
Comments