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 A160652 #16 Dec 07 2019 12:18:26 %S A160652 0,1,-2,3,4,-11,-6,7,-8,9,10,-5,12,13,-38,-33,16,-29,-18,25,-20,21,34, %T A160652 -35,-24,19,-26,27,28,-17,30,37,-32,-15,22,-23,36,31,-14,39,40,-119, %U A160652 -114,43,-92,-99,70,-65,48,97,-110,-87,52,-83,-54,79,-56,75,106,-101 %N A160652 Express n in balanced ternary, then reverse the digits, leaving any trailing zeros alone. %C A160652 This sequence, together with its negative extension a(-n) = -a(n) is a self-inverse permutation of the integers. The absolute values are a self-inverse permutation of the nonnegative integers. %H A160652 Indranil Ghosh, <a href="/A160652/b160652.txt">Table of n, a(n) for n = 0..6561</a> %F A160652 a(n) = A134028(n)*3^A007949(n). [_Franklin T. Adams-Watters_, May 24 2009] %e A160652 87 in balanced ternary is 101(-1)0; leaving the final 0 and reversing the remaining digits gives (-1)1010, which is -51; so a(87) = -51. %o A160652 (PARI) a(n)=local(r,dr,q);if(n==0,0,r=0;dr=1;while(n%3==0,dr*=3;n\=3);while(n!=0,q=(n+1)\3;r=3*r+dr*(n-3*q);n=q);r) \\ _Franklin T. Adams-Watters_, May 24 2009 %o A160652 (Python) %o A160652 def a(n): %o A160652 if n==0: return 0 %o A160652 r=0 %o A160652 dr=1 %o A160652 while n%3==0: %o A160652 dr*=3 %o A160652 n/=3 %o A160652 while n!=0: %o A160652 q=(n + 1)/3 %o A160652 r=3*r + dr*(n - 3*q) %o A160652 n=q %o A160652 return r %o A160652 ##print [a(n) for n in range(101)] # _Indranil Ghosh_, Jun 10 2017, after _Franklin T. Adams-Watters_ %Y A160652 Cf. A065363, A117962, A117966. %Y A160652 Cf. A057889, A134028, A007949. [_Franklin T. Adams-Watters_, May 24 2009] %K A160652 base,look,sign %O A160652 0,3 %A A160652 _Franklin T. Adams-Watters_, May 21 2009