A371635 For any number k >= 0, let T_k be the triangle with values in {-1, 0, +1} whose base corresponds to the balanced ternary expansion of k (without leading zeros) and other values, say t above u and v, satisfy t+u+v = 0 mod 3; the balanced ternary expansion of a(n) corresponds to the left border of T_n (the most significant digit being at the bottom left corner).
0, 1, 3, 2, 4, 10, 8, 9, 6, 7, 5, 11, 12, 13, 30, 29, 31, 24, 23, 25, 27, 26, 28, 18, 17, 19, 21, 20, 22, 15, 14, 16, 33, 32, 34, 36, 35, 37, 39, 38, 40, 91, 89, 90, 86, 87, 88, 93, 94, 92, 73, 71, 72, 68, 69, 70, 75, 76, 74, 82, 80, 81, 77, 78, 79, 84, 85, 83
Offset: 0
Examples
For n = 42: the balanced ternary expansion of 42 is "1TTT0" (where T denotes -1), and T_42 is as follows: T 0 1 1 T 0 0 T T 1 1 T T T 0 So the balanced ternary expansion of a(42) is "1010T", and a(42) = 89.
Links
Programs
-
PARI
a(n) = { my (b = [], d); while (n, b = concat(d = Mod(n, 3), b); n = (n-centerlift(d)) / 3;); my (t = vector(#b)); for (i = 1, #t, t[i] = centerlift(b[1]); b = -vector(#b-1, j, b[j]+b[j+1]);); fromdigits(t, 3); }
Comments