A079073 Sum of numbers < n having in binary representation the same number of 1's as n.
0, 0, 1, 0, 3, 3, 8, 0, 7, 14, 23, 7, 33, 18, 31, 0, 15, 45, 62, 45, 80, 64, 85, 15, 100, 107, 132, 38, 158, 65, 94, 0, 31, 124, 157, 186, 191, 221, 258, 124, 227, 296, 337, 163, 379, 206, 251, 31, 267, 423, 472, 297, 522, 348, 401, 78, 574, 455, 512, 133, 570, 192, 253, 0, 63
Offset: 0
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..16383
Programs
-
Maple
f:= n-> add(i, 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
a[n_] := Module[{dc = DigitCount[n, 2, 1]}, Select[Range[n-1], DigitCount[#, 2, 1] == dc&] // Total]; a /@ Range[0, 100] (* Jean-François Alcover, Nov 07 2020 *)
-
PARI
a(n) = my(s=hammingweight(n)); sum(k=1, n-1, if (s==hammingweight(k), k)); \\ Michel Marcus, Nov 07 2020