|
|
A056974
|
|
Number of blocks of {0, 0, 0} in the binary expansion of n.
|
|
10
|
|
|
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 4, 3, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 1, 0, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,16
|
|
COMMENTS
|
Overlaps count. For example, 64 in binary is 1000000, which means that a(64) = 4, not 2. - Harvey P. Dale, Jan 10 2016
|
|
LINKS
|
|
|
FORMULA
|
a(1) = 0, and then after, a(2n) = a(n) + [n congruent to 0 mod 8], a(2n+1) = a(n). - Ralf Stephan, Aug 22 2003, corrected by Antti Karttunen, Oct 10 2017
|
|
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, 0, 0}], {n, 1, 102} ] (* Jean-François Alcover, Oct 23 2012 *)
Table[SequenceCount[IntegerDigits[n, 2], {0, 0, 0}, Overlaps->True], {n, 110}] (* The program uses the SequenceCount function from Mathematica version 10 *) (* Harvey P. Dale, Jan 10 2016 *)
|
|
PROG
|
(PARI)
a(n) = {
my(x = bitor(n, bitor(n>>1, n>>2)));
if (x == 0, 0, 1 + logint(x, 2) - hammingweight(x))
};
(Scheme)
;; This uses Ralf Stephan's recurrence and memoization-macro definec:
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|