login
A246017
Partial sums of A246016.
2
1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 7, 6, 7, 8, 7, 8, 7, 6, 7, 6, 5, 6, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10, 9, 8, 9, 8, 9, 10, 9, 10, 11, 10, 11, 12, 11, 10, 11, 10, 9, 10, 9, 8, 9, 8, 9, 10, 9, 8, 9, 8
OFFSET
0,2
COMMENTS
This sequence and A246016 are the subject of the Lafrance et al. (2014) paper.
LINKS
Philip Lafrance, Narad Rampersad, Randy Yee, Some properties of a Rudin-Shapiro-like sequence, arXiv:1408.2277 [math.CO], 2014.
MATHEMATICA
b[n_] := b[n] = If[n == 0, 0, If[EvenQ[n], b[n/2] + DigitCount[n/2, 2, 1], b[(n - 1)/2] + 1]];
a55941[n_] := b[n] - DigitCount[n, 2, 1];
a[n_] := Sum[(-1)^a55941[k], {k, 0, n}];
Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Sep 23 2018 *)
PROG
(PARI) a055941(n) = {my(b=binary(n)); nb = 0; for (i=1, #b-1, if (b[i], nb += sum(j=i+1, #b, !b[j])); ); nb; }
a(n) = sum(k=0, n, (-1)^a055941(k));
(Python)
def A246017(n):
c = 0
for k in range(n+1):
a, b = 0, 1
for i, j in enumerate(bin(k)[:1:-1]):
if int(j):
a ^= (i&1)^(b:=b^1)
c += -1 if a else 1
return c # Chai Wah Wu, Jul 26 2023
CROSSREFS
KEYWORD
nonn,look
AUTHOR
STATUS
approved