OFFSET
0,7
REFERENCES
D. M. Bressoud, Proofs and Confirmations, Camb. Univ. Press, 1999; cf. p. 89.
LINKS
J. Stauduhar, Table of n, a(n) for n = 0..10000
FORMULA
Write n in binary; sum the positions where there is a '1' followed immediately to the right by a '0', counting the leftmost digit as position '1'.
EXAMPLE
50 = 110010 has 1's followed by 0's in positions 2 and 5 (reading from the left), so a(50)=7. At the beginning of the sequence we have 0->0, 1->0, 10->1, 11->0, 100->1, 101->1, 110->2, 111->0, 1000->1, 1001->1, 1010->1+3=4, ...
MATHEMATICA
a[n_] := Total[ Flatten[ Position[ IntegerDigits[n, 2] //. {b___, 1, 0, c___} -> {b, 2, 3, c}, 2]]]; Table[a[n], {n, 0, 102}] (* Jean-François Alcover, Dec 20 2011 *)
Table[Total[Flatten[Position[Partition[IntegerDigits[n, 2], 2, 1], {1, 0}]]], {n, 0, 110}] (* Harvey P. Dale, Nov 04 2012 *)
Table[Total[SequencePosition[IntegerDigits[n, 2], {1, 0}][[;; , 1]]], {n, 0, 110}] (* Harvey P. Dale, Feb 19 2023 *)
CROSSREFS
KEYWORD
nonn,base,nice,easy
AUTHOR
EXTENSIONS
More terms from Erich Friedman, Feb 19 2000
STATUS
approved