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 A165012 #17 Feb 24 2019 05:01:51 %S A165012 0,0,0,0,3,0,3,6,6,3,0,3,9,6,3,0,15,15,30,45,15,0,15,30,30,15,15,30, %T A165012 45,30,30,30,30,30,30,45,30,15,15,30,30,15,0,15,45,30,15,15,45,45,45, %U A165012 45,45,30,30,30,45,30,15,15,45,30,15,0,63,75,138,201,75,63,126,189,138,126 %N A165012 a(n) = image of n under the base-4 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order). %H A165012 Indranil Ghosh, <a href="/A165012/b165012.txt">Table of n, a(n) for n = 0..16384</a> (terms 0..1024 from Joseph Myers) %H A165012 <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a> %e A165012 For n = 11, 11_10 = 23_4. So, a(11) = 32_4 - 23_4 = 14 - 11 = 3. - _Indranil Ghosh_, Feb 02 2017 %t A165012 b4km[n_]:=Module[{idn4=Sort[IntegerDigits[n,4]]},FromDigits[ Reverse[ idn4],4]-FromDigits[idn4,4]]; Array[b4km,80,0] %o A165012 (PARI) cons(m) = {local(b, r); r=0; b=1; for(i=1, matsize(m)[2], r=r+b*m[i]; b=b*4); r} %o A165012 A165012(n) = {local(m, r); r=[]; m=n; while(m>0, r=concat(m%4, r); m=floor(m/4)); cons(vecsort(r,,0))-cons(vecsort(r,,4))} \\ _Michael B. Porter_, Nov 05 2009 %Y A165012 Cf. A165013. %Y A165012 In other bases: A164884 (base 2), A164993 (base 3), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9), A151949 (base 10). %K A165012 base,nonn %O A165012 0,5 %A A165012 _Joseph Myers_, Sep 04 2009