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 A372783 #17 Jun 02 2024 08:21:51 %S A372783 0,1,2,4,3,5,7,6,8,13,12,14,10,9,11,16,15,17,22,21,23,19,18,20,25,24, %T A372783 26,40,39,41,37,36,38,43,42,44,31,30,32,28,27,29,34,33,35,49,48,50,46, %U A372783 45,47,52,51,53,67,66,68,64,63,65,70,69,71,58,57,59,55,54 %N A372783 In the ternary expansion of n: keep the initial digit, and then replace 0's with 1's and 1's with 0's. %C A372783 This sequence is a self-inverse permutation of the nonnegative integers. %H A372783 Rémy Sigrist, <a href="/A372783/b372783.txt">Table of n, a(n) for n = 0..6560</a> %H A372783 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A372783 a(n) = n iff n belongs to A062318. %e A372783 For n = 42: the ternary expansion of 42 is "1120", so the ternary expansion of a(42) is "1021", and a(42) = 34. %t A372783 Table[t3=IntegerDigits[n,3];fd=First[t3];tr=Rest[t3]/.{1->0,0->1};PrependTo[tr,fd];FromDigits[tr,3],{n,0,67}] (* _James C. McMahon_, May 31 2024 *) %o A372783 (PARI) a(n) = { my (t = digits(n, 3)); for (i = 2, #t, t[i] = [1,0,2][1+t[i]];); fromdigits(t, 3); } %Y A372783 Cf. A004488, A062318 (fixed points), A115303. %K A372783 nonn,base,look,easy %O A372783 0,3 %A A372783 _Rémy Sigrist_, May 13 2024