cp's OEIS Frontend

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.

A164884 a(n) = image of n under the base-2 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order).

This page as a plain text file.
%I A164884 #20 Apr 09 2020 10:27:17
%S A164884 0,0,1,0,3,3,3,0,7,9,9,7,9,7,7,0,15,21,21,21,21,21,21,15,21,21,21,15,
%T A164884 21,15,15,0,31,45,45,49,45,49,49,45,45,49,49,45,49,45,45,31,45,49,49,
%U A164884 45,49,45,45,31,49,45,45,31,45,31,31,0,63,93,93,105,93,105,105,105,93,105,105
%N A164884 a(n) = image of n under the base-2 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order).
%H A164884 Indranil Ghosh, <a href="/A164884/b164884.txt">Table of n, a(n) for n = 0..16384</a> (terms 0..1024 from Joseph Myers)
%H A164884 <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a>
%e A164884 For n = 17, 17_10 = 10001_2. So, a(17) = 11000_2 - 11_2 = 24 - 3 = 21. - _Indranil Ghosh_, Feb 01 2017
%t A164884 a[n_] := With[{dd = IntegerDigits[n, 2]}, FromDigits[ReverseSort[dd], 2] - FromDigits[Sort[dd], 2]];
%t A164884 a /@ Range[0, 100] (* _Jean-François Alcover_, Jan 08 2020 *)
%o A164884 (Python)
%o A164884 def A164884(n):
%o A164884     return int("".join(sorted(bin(n)[2:],reverse=True)),2)-int("".join(sorted(bin(n)[2:])),2) # _Indranil Ghosh_, Feb 01 2017
%Y A164884 Cf. A163205, A164885, A164886, A164887.
%Y A164884 In other bases: A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9), A151949 (base 10).
%K A164884 base,nonn
%O A164884 0,5
%A A164884 _Joseph Myers_, Aug 29 2009
%E A164884 Cross-references edited by _Joseph Myers_, Sep 04 2009