%I #8 May 03 2022 16:51:43
%S 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,
%T 47,27,41,28,42,26,43,29,46,30,51,20,52,21,53,22,54,31,59,153,32,48,
%U 33,49,35,55,36,56,34,57,37,68,39,69,38,70,134,40,71,132,72
%N Lexicographically earliest sequence of distinct nonnegative integers such that two consecutive terms can be added without carries in balanced ternary.
%C Two integers can be added without carries in balanced ternary if they have no equal nonzero digit at the same position.
%C This sequence is a permutation of the nonnegative integers with inverse A353650.
%H Rémy Sigrist, <a href="/A353649/b353649.txt">Table of n, a(n) for n = 0..10000</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e The first terms, in decimal and in balanced ternary, are:
%e n a(n) bter(a(n))
%e -- ---- ----------
%e 0 0 0
%e 1 1 1
%e 2 2 1T
%e 3 6 1T0
%e 4 3 10
%e 5 5 1TT
%e 6 4 11
%e 7 8 10T
%e 8 15 1TT0
%e 9 9 100
%e 10 14 1TTT
%e 11 10 101
%e 12 17 1T0T
%e 13 7 1T1
%e 14 18 1T00
%o (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 }
%o { 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))) }
%Y Cf. A059095, A109812 (binary analog), A353648, A353650 (inverse).
%K nonn,look,base
%O 0,3
%A _Rémy Sigrist_, May 01 2022
|