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 A165090 #24 Jun 02 2025 02:01:17 %S A165090 0,0,0,0,0,0,0,0,7,0,7,14,21,28,35,42,14,7,0,7,14,21,28,35,21,14,7,0, %T A165090 7,14,21,28,28,21,14,7,0,7,14,21,35,28,21,14,7,0,7,14,42,35,28,21,14, %U A165090 7,0,7,49,42,35,28,21,14,7,0,63,63,126,189,252,315,378,441,63,0,63,126,189 %N A165090 a(n) is the image of n under the base-8 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order). %H A165090 Indranil Ghosh, <a href="/A165090/b165090.txt">Table of n, a(n) for n = 0..32768</a> (terms 0..4096 from Joseph Myers) %H A165090 <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a> %e A165090 For n = 11, 11_10 = 13_8. So, a(11) = 31_8 - 13_8 = 25 - 11 = 14. - _Indranil Ghosh_, Feb 02 2017 %t A165090 a[n_] := With[{dd = IntegerDigits[n, 8]}, FromDigits[ReverseSort[dd], 8] - FromDigits[Sort[dd], 8]]; %t A165090 a /@ Range[0, 100] (* _Jean-François Alcover_, Jan 08 2020 *) %o A165090 (Python) %o A165090 def A165090(n): %o A165090 if n==0:return 0 %o A165090 return int("".join(sorted(oct(n)[2:],reverse=True)),8)-int("".join(sorted(oct(n)[2:])),8) # _Indranil Ghosh_, Feb 02 2017 %Y A165090 Cf. A165091. %Y A165090 In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165110 (base 9), A151949 (base 10). %K A165090 base,nonn %O A165090 0,9 %A A165090 _Joseph Myers_, Sep 04 2009