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 A048647 #62 Jan 29 2023 17:04:41 %S A048647 0,3,2,1,12,15,14,13,8,11,10,9,4,7,6,5,48,51,50,49,60,63,62,61,56,59, %T A048647 58,57,52,55,54,53,32,35,34,33,44,47,46,45,40,43,42,41,36,39,38,37,16, %U A048647 19,18,17,28,31,30,29,24,27,26,25,20,23,22,21,192,195,194,193,204,207,206 %N A048647 Write n in base 4, then replace each digit '1' with '3' and vice versa and convert back to decimal. %C A048647 The graph of a(n) on [ 1..4^k ] resembles a plane fractal of fractal dimension 1. %C A048647 Self-inverse considered as a permutation of the integers. %C A048647 First 4^n terms of the sequence form a permutation s(n) of 0..4^n-1, n>=1; the number of inversions of s(n) is A115490(n). - _Gheorghe Coserea_, Apr 23 2018 %H A048647 Reinhard Zumkeller, <a href="/A048647/b048647.txt">Table of n, a(n) for n = 0..16383</a> %H A048647 J. W. Layman, <a href="http://intranet.math.vt.edu/people/layman/sequences/sequences.htm">View fractal-like graph</a> %H A048647 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A048647 a(n) = if n = 0 then 0 else 4*a(floor(n/4)) + if m = 0 then 0 else 4 - m, where m = n mod 4. - _Reinhard Zumkeller_, Apr 08 2013 %F A048647 G.f. g(x) satisfies: g(x) = 4*(1+x+x^2+x^3)*g(x^4) + (3*x+2*x^2+x^3)/(1-x^4). - _Robert Israel_, Nov 03 2014 %e A048647 a(15)=5, since 15 = 33_4 -> 11_4 = 5. %p A048647 f:= proc(n) %p A048647 option remember; %p A048647 local m, r; %p A048647 m:= n mod 4; %p A048647 r:= 4*procname((n-m)/4); %p A048647 if m = 0 then r else r + 4-m fi; %p A048647 end proc: %p A048647 f(0):= 0: %p A048647 seq(f(n),n=0..100); # _Robert Israel_, Nov 03 2014 %p A048647 # second Maple program: %p A048647 a:= proc(n) option remember; `if`(n=0, 0, %p A048647 a(iquo(n, 4, 'r'))*4+[0, 3, 2, 1][r+1]) %p A048647 end: %p A048647 seq(a(n), n=0..70); # _Alois P. Heinz_, Jan 25 2022 %t A048647 Table[FromDigits[If[#==0,0,4-#]&/@IntegerDigits[n,4],4],{n,0,70}] (* _Harvey P. Dale_, Jul 23 2012 *) %o A048647 (Haskell) %o A048647 a048647 0 = 0 %o A048647 a048647 n = 4 * a048647 n' + if m == 0 then 0 else 4 - m %o A048647 where (n', m) = divMod n 4 %o A048647 -- _Reinhard Zumkeller_, Apr 08 2013 %o A048647 (PARI) a(n)=fromdigits(apply(d->if(d,4-d),digits(n,4)),4) \\ _Charles R Greathouse IV_, Jun 23 2017 %o A048647 (Python) %o A048647 from sympy.ntheory.factor_ import digits %o A048647 def a(n): %o A048647 return int("".join(str(4 - d) if d!=0 else '0' for d in digits(n, 4)[1:]), 4) %o A048647 print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 26 2017 %o A048647 (Python) %o A048647 def A048647(n): return n^((n&((1<<(m:=n.bit_length())+(m&1))-1)//3)<<1) # _Chai Wah Wu_, Jan 29 2023 %o A048647 (C) uint32_t a(uint32_t n) { return n ^ ((n & 0x55555555) << 1); } // _Falk Hüffner_, Jan 22 2022 %Y A048647 Cf. A065256, A007090. %Y A048647 Column k=4 of A248813. %K A048647 nonn,easy,nice,base,look %O A048647 0,2 %A A048647 _John W. Layman_, Jul 05 1999