A079074 Sum of numbers < n having in binary representation the same number of 0's and 1's as n.
0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 9, 0, 19, 11, 24, 0, 0, 0, 17, 0, 35, 19, 40, 0, 55, 62, 87, 23, 113, 50, 79, 0, 0, 0, 33, 0, 67, 35, 72, 0, 103, 110, 151, 39, 193, 82, 127, 0, 143, 237, 286, 173, 336, 224, 277, 47, 388, 331, 388, 102, 446, 161, 222, 0, 0, 0, 65, 0, 131, 67, 136, 0
Offset: 0
Keywords
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..16383
Programs
-
Maple
f:= n-> (x-> (t-> t*(t+1)/2+x[2])(x[1]+x[2]))(add( `if`(i=0, [1, 0], [0, 1]), i=convert(n, base, 2))): b:= proc(n) b(n):= b(n-1)+n*x^f(n) end: b(-1):=0: a:= n-> coeff(b(n-1), x, f(n)): seq(a(n), n=0..150); # Alois P. Heinz, Feb 08 2018
-
Mathematica
bdQ[m_,n_]:=Module[{a=DigitCount[m,2,0],b=DigitCount[m,2,1], c= DigitCount[ n,2,0], d=DigitCount[ n,2,1]}, a==c&&b==d]; Table[Total[ Select[Range[n-1],bdQ[#,n]&]],{n,80}] (* Harvey P. Dale, Sep 08 2011 *)
Comments