|
|
A056976
|
|
Number of blocks of {0, 1, 0} in the binary expansion of n.
|
|
10
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 2, 1, 0, 0, 0, 0, 1, 1, 2, 1, 2, 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,42
|
|
LINKS
|
|
|
FORMULA
|
a(2n) = a(n) + [n>1 and n congruent to 1 mod 4], a(2n+1) = a(n). - Ralf Stephan, Aug 22 2003
|
|
MATHEMATICA
|
a[n_, bits_] := (idn = IntegerDigits[n, 2]; ln = Length[idn]; lb = Length[bits]; For[cnt = 0; k = 1, k <= ln - lb + 1, k++, If[idn[[k ;; k + lb - 1]] == bits, cnt++]]; cnt); Table[ a[n, {0, 1, 0}], {n, 1, 102} ] (* Jean-François Alcover, Oct 23 2012 *)
Table[SequenceCount[IntegerDigits[n, 2], {0, 1, 0}, Overlaps->True], {n, 120}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 11 2019 *)
|
|
PROG
|
(PARI)
a(n) = {
if (n < 10, return(0));
my(k = logint(n, 2) - 1);
hammingweight(bitnegimply(n>>1, bitor(n, n >> 2))) - !bittest(n, k)
};
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|