login
A335587
a(n) is the sum of the numbers k such that 0 <= k <= n and n AND k = 0 (where AND denotes the bitwise AND operator).
2
0, 0, 1, 0, 6, 2, 1, 0, 28, 12, 10, 4, 6, 2, 1, 0, 120, 56, 52, 24, 44, 20, 18, 8, 28, 12, 10, 4, 6, 2, 1, 0, 496, 240, 232, 112, 216, 104, 100, 48, 184, 88, 84, 40, 76, 36, 34, 16, 120, 56, 52, 24, 44, 20, 18, 8, 28, 12, 10, 4, 6, 2, 1, 0, 2016, 992, 976, 480
OFFSET
0,5
COMMENTS
All terms can be written as m * 2^A000120(m) for some m >= 0.
FORMULA
a(n) = A035327(n) * A080100(n) / 2 for any n > 0.
a(2*n+1) = 2*a(n).
a(2^k-1) = 0 for any k >= 0.
a(2^k) = A006516(k) for any k >= 0.
EXAMPLE
For n = 4:
- 4 AND 0 = 0,
- 4 AND 1 = 0,
- 4 AND 2 = 0,
- 4 AND 3 = 0,
- 4 AND 4 = 4,
- so a(4) = 0 + 1 + 2 + 3 = 6.
PROG
(PARI) a(n) = sum(k=0, n, if (bitand(n, k)==0, k, 0))
(PARI) a(n) = my (w=#binary(n)); ( (2^w-1-n) * 2^(w-hammingweight(n)) ) \ 2
CROSSREFS
Cf. A000120, A004198 (bitwise AND), A006516, A035327, A080100, A080791.
Sequence in context: A120002 A296432 A171542 * A320302 A284761 A021165
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 21 2021
STATUS
approved