login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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
Eric Weisstein's World of Mathematics, Digit Block
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(v=binary(n)); sum(i=3, #v, v[i]+v[i-1]+v[i-2]==0) \\ Charles R Greathouse IV, Dec 07 2011
(PARI)
a(n) = {
my(x = bitor(n, bitor(n>>1, n>>2)));
if (x == 0, 0, 1 + logint(x, 2) - hammingweight(x))
};
vector(102, i, a(i)) \\ Gheorghe Coserea, Sep 17 2015
(Scheme)
;; This uses Ralf Stephan's recurrence and memoization-macro definec:
(definec (A056974 n) (cond ((= 1 n) 0) ((even? n) (+ (if (zero? (modulo n 8)) 1 0) (A056974 (/ n 2)))) (else (A056974 (/ (- n 1) 2))))) ;; Antti Karttunen, Oct 10 2017
CROSSREFS
Sequence in context: A037877 A010109 A304021 * A368844 A181563 A056976
KEYWORD
nonn,base,easy
AUTHOR
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 17:29 EDT 2024. Contains 371962 sequences. (Running on oeis4.)