A079071 Number of numbers < n whose binary representation has the same number of 0's and 1's as n does.
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 1, 2, 0, 0, 0, 1, 0, 2, 1, 2, 0, 3, 3, 4, 1, 5, 2, 3, 0, 0, 0, 1, 0, 2, 1, 2, 0, 3, 3, 4, 1, 5, 2, 3, 0, 4, 6, 7, 4, 8, 5, 6, 1, 9, 7, 8, 2, 9, 3, 4, 0, 0, 0, 1, 0, 2, 1, 2, 0, 3, 3, 4, 1, 5, 2, 3, 0, 4, 6, 7, 4, 8, 5, 6, 1, 9, 7, 8, 2, 9, 3, 4, 0, 5, 10, 11, 10, 12, 11, 12
Offset: 0
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)+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
a[n_] := Count[Range[n-1], k_ /; DigitCount[n, 2] == DigitCount[k, 2]]; Table[a[n], {n, 0, 104}] (* Jean-François Alcover, Feb 13 2018 *)