[go: up one dir, main page]

login
A353649
Lexicographically earliest sequence of distinct nonnegative integers such that two consecutive terms can be added without carries in balanced ternary.
3
0, 1, 2, 6, 3, 5, 4, 8, 15, 9, 14, 10, 17, 7, 18, 11, 16, 12, 19, 50, 13, 23, 45, 24, 44, 25, 47, 27, 41, 28, 42, 26, 43, 29, 46, 30, 51, 20, 52, 21, 53, 22, 54, 31, 59, 153, 32, 48, 33, 49, 35, 55, 36, 56, 34, 57, 37, 68, 39, 69, 38, 70, 134, 40, 71, 132, 72
OFFSET
0,3
COMMENTS
Two integers can be added without carries in balanced ternary if they have no equal nonzero digit at the same position.
This sequence is a permutation of the nonnegative integers with inverse A353650.
EXAMPLE
The first terms, in decimal and in balanced ternary, are:
n a(n) bter(a(n))
-- ---- ----------
0 0 0
1 1 1
2 2 1T
3 6 1T0
4 3 10
5 5 1TT
6 4 11
7 8 10T
8 15 1TT0
9 9 100
10 14 1TTT
11 10 101
12 17 1T0T
13 7 1T1
14 18 1T00
PROG
(PARI) ok(u, v) = { while (u && v, my (uu=[0, +1, -1][1+u%3], vv=[0, +1, -1][1+v%3]); if (abs(uu+vv)>1, return (0)); u=(u-uu)/3; v=(v-vv)/3); 1 }
{ s=0; v=0; for (n=0, 66, print1 (v", "); s+=2^v; for (w=0, oo, if (!bittest(s, w) && ok(v, w), v=w; break))) }
CROSSREFS
Cf. A059095, A109812 (binary analog), A353648, A353650 (inverse).
Sequence in context: A351496 A154048 A259018 * A084355 A093650 A064433
KEYWORD
nonn,look,base
AUTHOR
Rémy Sigrist, May 01 2022
STATUS
approved