login
Difference between the largest and smallest number having in binary representation the same number of 0's and 1's as n.
5

%I #11 Aug 11 2014 22:45:22

%S 0,0,0,0,0,1,1,0,0,3,3,3,3,3,3,0,0,7,7,9,7,9,9,7,7,9,9,7,9,7,7,0,0,15,

%T 15,21,15,21,21,21,15,21,21,21,21,21,21,15,15,21,21,21,21,21,21,15,21,

%U 21,21,15,21,15,15,0,0,31,31,45,31,45,45,49,31,45,45,49,45,49,49,45,31

%N Difference between the largest and smallest number having in binary representation the same number of 0's and 1's as n.

%C a(n) = A073138(n) - A073137(n).

%H Harvey P. Dale, <a href="/A073139/b073139.txt">Table of n, a(n) for n = 0..1000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%t d[n_]:=Module[{idn2=IntegerDigits[n,2]},FromDigits[Sort[idn2,#1>#2&],2]- FromDigits[ RotateRight[Sort[idn2],1],2]]; Array[d,90,0] (* _Harvey P. Dale_, Oct 22 2011 *)

%Y Cf. A007088, A073140, A073141.

%K nonn

%O 0,10

%A _Reinhard Zumkeller_, Jul 16 2002