This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A353648 #10 May 03 2022 17:10:34 %S A353648 0,2,1,5,6,3,4,17,15,14,18,16,19,23,9,8,11,7,10,12,51,50,53,13,44,45, %T A353648 42,41,47,43,46,54,48,49,56,52,55,57,69,68,71,27,26,29,24,25,30,28,32, %U A353648 33,21,20,35,22,31,36,34,37,149,153,152,155,150,151,156,154 %N A353648 Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, n and a(n) can be added without carries in balanced ternary. %C A353648 Two integers can be added without carries in balanced ternary if they have no equal nonzero digit at the same position. %C A353648 This sequence is a self-inverse permutation of the nonnegative integers with a single fixed point: a(0) = 0. %H A353648 Rémy Sigrist, <a href="/A353648/b353648.txt">Table of n, a(n) for n = 0..10000</a> %H A353648 Wikipedia, <a href="https://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a> %H A353648 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %e A353648 The first terms, in decimal and in balanced ternary, are: %e A353648 n | 0 1 2 3 4 5 6 7 8 9 10 11 12 %e A353648 a(n) | 0 2 1 5 6 3 4 17 15 14 18 16 19 %e A353648 bter(n) | 0 1 1T 10 11 1TT 1T0 1T1 10T 100 101 11T 110 %e A353648 bter(a(n))| 0 1T 1 1TT 1T0 10 11 1T0T 1TT0 1TTT 1T00 1TT1 1T01 %o A353648 (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 A353648 { s=0; for (n=0, 65, for (v=0, oo, if (!bittest(s,v) && ok(n,v), print1 (v", "); s+=2^v; break))) } %Y A353648 Cf. A059095, A238757 (binary analog), A353649. %K A353648 nonn,look,base %O A353648 0,2 %A A353648 _Rémy Sigrist_, May 01 2022