OFFSET
0,5
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..16384 (terms 0..1024 from Joseph Myers)
EXAMPLE
For n = 17, 17_10 = 10001_2. So, a(17) = 11000_2 - 11_2 = 24 - 3 = 21. - Indranil Ghosh, Feb 01 2017
MATHEMATICA
a[n_] := With[{dd = IntegerDigits[n, 2]}, FromDigits[ReverseSort[dd], 2] - FromDigits[Sort[dd], 2]];
a /@ Range[0, 100] (* Jean-François Alcover, Jan 08 2020 *)
PROG
(Python)
def A164884(n):
return int("".join(sorted(bin(n)[2:], reverse=True)), 2)-int("".join(sorted(bin(n)[2:])), 2) # Indranil Ghosh, Feb 01 2017
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Joseph Myers, Aug 29 2009
EXTENSIONS
Cross-references edited by Joseph Myers, Sep 04 2009
STATUS
approved