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 A331364 #52 Jun 27 2020 14:21:56 %S A331364 0,1,2,3,4,5,9,13,8,6,10,14,12,7,11,15,16,17,33,49,65,81,41,61,36,38, %T A331364 37,177,52,55,225,53,32,18,34,50,24,26,25,114,130,22,162,62,56,210,59, %U A331364 58,48,19,35,51,28,31,99,29,44,147,47,46,195,23,43,243,64 %N A331364 If the set of nonzero digits of n in some base of the form 2^2^k (with k >= 0) has exactly two elements, let b be the least such base and u and v the corresponding two nonzero digits; the base b representation of a(n) is obtained by replacing the u's by v's and vice versa in the base b representation of n; otherwise a(n) = n. %C A331364 This sequence is a self-inverse permutation of the nonnegative integers. See A332520 for the corresponding fixed points. %C A331364 For any m > 1, we can devise a similar sequence by considering bases of the form m^2^k (with k >= 0). %H A331364 Rémy Sigrist, <a href="/A331364/b331364.txt">Table of n, a(n) for n = 0..65536</a> %H A331364 Rémy Sigrist, <a href="/A331364/a331364.png">Scatterplot of the first 2^2^4 terms</a> %H A331364 Rémy Sigrist, <a href="/A331364/a331364_1.png">Colored scatterplot of the first 2^2^4 terms</a> (where the color denotes the base b if any) %H A331364 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A331364 a(n) < 2^2^k iff n < 2^2^k for any n, k >= 0. %F A331364 a(2^k) = 2^k for any k >= 0. %F A331364 a(2^2^k-1) = 2^2^k-1 for any k >= 0. %e A331364 For n = 73: %e A331364 - the base 2^2^0 representation of 73 is "1001001" which has only one kind of nonzero digits, %e A331364 - the base 2^2^1 representation of 73 is "1021" which has exactly two kinds of nonzero digits, "1" and "2", %e A331364 - so the base 2^2^1 representation of a(73) is "2012", %e A331364 - and a(73) = 134. %o A331364 (PARI) a(n) = { for (x=0, oo, my (b=2^2^x, d=if (n, digits(n, b), [0])); if (#d==1, return (n), my (uv=select(sign, Set(d))); if (#uv==2, return ( %o A331364 fromdigits(apply (t -> if (t==0, 0, t==uv[1], uv[2], uv[1]), d), b))))) } %Y A331364 Cf. A001146, A332520 (fixed points). %K A331364 nonn,base %O A331364 0,3 %A A331364 _Rémy Sigrist_, Jun 24 2020