A055941 a(n) = Sum_{j=0..k-1} (i(j) - j) where n = Sum_{j=0..k-1} 2^i(j).
0, 0, 1, 0, 2, 1, 2, 0, 3, 2, 3, 1, 4, 2, 3, 0, 4, 3, 4, 2, 5, 3, 4, 1, 6, 4, 5, 2, 6, 3, 4, 0, 5, 4, 5, 3, 6, 4, 5, 2, 7, 5, 6, 3, 7, 4, 5, 1, 8, 6, 7, 4, 8, 5, 6, 2, 9, 6, 7, 3, 8, 4, 5, 0, 6, 5, 6, 4, 7, 5, 6, 3, 8, 6, 7, 4, 8, 5, 6, 2, 9, 7, 8, 5, 9, 6, 7, 3, 10, 7, 8, 4, 9, 5, 6, 1, 10, 8, 9, 6, 10, 7, 8, 4
Offset: 0
Examples
20 = 2^4 + 2^2, thus a(20) = (2-0) + (4-1) = 5.
References
- A. Siegel, Linear Aspects of Boolean Functions, 1999 (unpublished).
Links
- Chai Wah Wu, Table of n, a(n) for n = 0..10000
- Philip Lafrance, Narad Rampersad and Randy Yee, Some properties of a Rudin-Shapiro-like sequence, arXiv:1408.2277 [math.CO], 2014 (see page 2).
Programs
-
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]]; a[n_] := b[n] - DigitCount[n, 2, 1]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Sep 23 2018 *)
-
PARI
a(n) = {my(b=binary(n)); nb = 0; for (i=1, #b-1, if (b[i], nb += sum(j=i+1, #b, !b[j]));); nb;} \\ Michel Marcus, Aug 12 2014
-
Python
def A055941(n): s = bin(n)[2:] return sum(s[i:].count('0') for i,d in enumerate(s,start=1) if d == '1') # Chai Wah Wu, Sep 07 2014
Formula
Extensions
Edited and extended by Antti Karttunen, Oct 12 2009
Comments