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.
LINKS
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
KEYWORD
AUTHOR
Rémy Sigrist, May 01 2022
STATUS
approved