%I #22 Apr 10 2020 15:11:28
%S 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 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 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 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 Indranil Ghosh, <a href="/A165090/b165090.txt">Table of n, a(n) for n = 0..32768</a> (terms 0..4096 from Joseph Myers)
%H <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a>
%e For n = 11, 11_10 = 13_8. So, a(11) = 31_8 - 13_8 = 25 - 11 = 14. - _Indranil Ghosh_, Feb 02 2017
%t a[n_] := With[{dd = IntegerDigits[n, 8]}, FromDigits[ReverseSort[dd], 8] - FromDigits[Sort[dd], 8]];
%t a /@ Range[0, 100] (* _Jean-François Alcover_, Jan 08 2020 *)
%o (Python)
%o def A165090(n):
%o if n==0:return 0
%o return int("".join(sorted(oct(n)[2:],reverse=True)),8)-int("".join(sorted(oct(n)[2:])),8) # _Indranil Ghosh_, Feb 02 2017
%Y Cf. A165091.
%Y 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 base,nonn
%O 0,9
%A _Joseph Myers_, Sep 04 2009
|