OFFSET
0,2
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 self-inverse permutation of the nonnegative integers with a single fixed point: a(0) = 0.
LINKS
EXAMPLE
The first terms, in decimal and in balanced ternary, are:
n | 0 1 2 3 4 5 6 7 8 9 10 11 12
a(n) | 0 2 1 5 6 3 4 17 15 14 18 16 19
bter(n) | 0 1 1T 10 11 1TT 1T0 1T1 10T 100 101 11T 110
bter(a(n))| 0 1T 1 1TT 1T0 10 11 1T0T 1TT0 1TTT 1T00 1TT1 1T01
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; for (n=0, 65, for (v=0, oo, if (!bittest(s, v) && ok(n, v), print1 (v", "); s+=2^v; break))) }
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, May 01 2022
STATUS
approved