OFFSET
0
COMMENTS
This sequence and A246017 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_] := (-1)^a55941[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) = (-1)^a055941(n);
(Python)
def A246016(n):
a, b = 0, 0
for i, j in enumerate(bin(n)[:1:-1]):
if int(j):
a ^= (i&1)^b
b ^= 1
return -1 if a else 1 # Chai Wah Wu, Jul 26 2023
CROSSREFS
KEYWORD
sign
AUTHOR
Michel Marcus and N. J. A. Sloane, Aug 13 2014
STATUS
approved