Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #11 Jan 08 2020 09:43:25
%S 0,0,0,0,0,0,0,0,0,8,0,8,16,24,32,40,48,56,16,8,0,8,16,24,32,40,48,24,
%T 16,8,0,8,16,24,32,40,32,24,16,8,0,8,16,24,32,40,32,24,16,8,0,8,16,24,
%U 48,40,32,24,16,8,0,8,16,56,48,40,32,24,16,8,0,8,64,56,48,40,32,24,16,8
%N a(n) = image of n under the base-9 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order)
%H Indranil Ghosh, <a href="/A165110/b165110.txt">Table of n, a(n) for n = 0..59049</a> (terms 0..6561 from Joseph Myers)
%H <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a>
%e For n = 11, 11_10 = 12_9. So, a(11) = 21_9 - 12_9 = 19 - 11 = 8. - _Indranil Ghosh_, Feb 02 2017
%t a[n_] := With[{dd = IntegerDigits[n, 9]}, FromDigits[ReverseSort[dd], 9] - FromDigits[Sort[dd], 9]];
%t a /@ Range[0, 100] (* _Jean-François Alcover_, Jan 08 2020 *)
%Y Cf. A165111.
%Y In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A151949 (base 10).
%K base,nonn
%O 0,10
%A _Joseph Myers_, Sep 04 2009