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 A117968 #20 Mar 11 2021 18:03:04 %S A117968 2,7,6,8,22,21,23,19,18,20,25,24,26,67,66,68,64,63,65,70,69,71,58,57, %T A117968 59,55,54,56,61,60,62,76,75,77,73,72,74,79,78,80,202,201,203,199,198, %U A117968 200,205,204,206,193,192,194,190,189,191,196,195,197,211,210,212,208,207 %N A117968 Negative part of inverse of A117966; write -n in balanced ternary and then replace (-1)'s with 2's. %D A117968 D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 2, pp. 173-175 %H A117968 Indranil Ghosh, <a href="/A117968/b117968.txt">Table of n, a(n) for n = 1..6561</a> %H A117968 Ken Levasseur, <a href="http://discretemath.org/ternary_number_system.html">The Balanced Ternary Number System</a> %F A117968 a(1) = 2, a(3n) = 3a(n), a(3n+1) = 3a(n)+2, a(3n-1) = 3a(n)+1. %e A117968 -7 in balanced ternary is (-1)1(-1), changing to 212 ternary is 23, so a(7)=23. %o A117968 (Python) %o A117968 def a(n): %o A117968 if n==1: return 2 %o A117968 if n%3==0: return 3*a(n//3) %o A117968 elif n%3==1: return 3*a((n - 1)//3) + 2 %o A117968 else: return 3*a((n + 1)//3) + 1 %o A117968 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jun 06 2017 %Y A117968 Cf. A117966. a(n) = A004488(A117967(n)). Bisection of A140263. A140268 gives the same sequence in ternary. %K A117968 base,nonn %O A117968 1,1 %A A117968 _Franklin T. Adams-Watters_, Apr 05 2006