cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 15 results. Next

A014081 a(n) is the number of occurrences of '11' in the binary expansion of n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 2, 2, 2, 3, 4, 0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 3, 3, 3, 4, 5, 0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 1
Offset: 0

Views

Author

Keywords

Comments

a(n) takes the value k for the first time at n = 2^(k+1)-1. Cf. A000225. - Robert G. Wilson v, Apr 02 2009
a(n) = A213629(n,3) for n > 2. - Reinhard Zumkeller, Jun 17 2012

Examples

			The binary expansion of 15 is 1111, which contains three occurrences of 11, so a(15)=3.
		

Crossrefs

First differences give A245194.
A245195 gives 2^a(n).

Programs

  • Haskell
    import Data.Bits ((.&.))
    a014081 n = a000120 (n .&. div n 2)  -- Reinhard Zumkeller, Jan 23 2012
    
  • Maple
    # To count occurrences of 11..1 (k times) in binary expansion of v:
    cn := proc(v, k) local n, s, nn, i, j, som, kk;
    som := 0;
    kk := convert(cat(seq(1, j = 1 .. k)),string);
    n := convert(v, binary);
    s := convert(n, string);
    nn := length(s);
    for i to nn - k + 1 do
    if substring(s, i .. i + k - 1) = kk then som := som + 1 fi od;
    som; end; # This program no longer worked. Corrected by N. J. A. Sloane, Apr 06 2014.
    [seq(cn(n,2),n=0..300)];
    # Alternative:
    A014081 := proc(n) option remember;
      if n mod 4 <= 1 then procname(floor(n/4))
    elif n mod 4 = 2 then procname(n/2)
    else 1 + procname((n-1)/2)
    fi
    end proc:
    A014081(0):= 0:
    map(A014081, [$0..1000]); # Robert Israel, Sep 04 2015
  • Mathematica
    f[n_] := Count[ Partition[ IntegerDigits[n, 2], 2, 1], {1, 1}]; Table[ f@n, {n, 0, 104}] (* Robert G. Wilson v, Apr 02 2009 *)
    Table[SequenceCount[IntegerDigits[n,2],{1,1},Overlaps->True],{n,0,120}] (* Harvey P. Dale, Jun 06 2022 *)
  • PARI
    A014081(n)=sum(i=0,#binary(n)-2,bitand(n>>i,3)==3)  \\ M. F. Hasler, Jun 06 2012
    
  • PARI
    a(n) = hammingweight(bitand(n, n>>1)) ;
    vector(105, i, a(i-1))  \\ Gheorghe Coserea, Aug 30 2015
    
  • Python
    def a(n): return sum([((n>>i)&3==3) for i in range(len(bin(n)[2:]) - 1)]) # Indranil Ghosh, Jun 03 2017
    
  • Python
    from re import split
    def A014081(n): return sum(len(d)-1 for d in split('0+', bin(n)[2:]) if d != '') # Chai Wah Wu, Feb 04 2022

Formula

a(4n) = a(4n+1) = a(n), a(4n+2) = a(2n+1), a(4n+3) = a(2n+1) + 1. - Ralf Stephan, Aug 21 2003
G.f.: (1/(1-x)) * Sum_{k>=0} t^3/((1+t)*(1+t^2)), where t = x^(2^k). - Ralf Stephan, Sep 10 2003
a(n) = A000120(n) - A069010(n). - Ralf Stephan, Sep 10 2003
Sum_{n>=1} A014081(n)/(n*(n+1)) = A100046 (Allouche and Shallit, 1990). - Amiram Eldar, Jun 01 2021

A003726 Numbers with no 3 adjacent 1's in binary expansion.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 48, 49, 50, 51, 52, 53, 54, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 76, 77, 80, 81, 82
Offset: 1

Views

Author

Keywords

Comments

Positions of zeros in A014082. Could be called "tribbinary numbers" by analogy with A003714. - John Keith, Mar 07 2022
The sequence of Tribbinary numbers can be constructed by writing out the Tribonacci representations of nonnegative integers and then evaluating the result in binary. These numbers are similar to Fibbinary numbers A003714, Fibternary numbers A003726, and Tribternary numbers A356823. The number of Tribbinary numbers less than any power of two is a Tribonacci number. We can generate Tribbinary numbers recursively: Start by adding 0 and 1 to the sequence. Then, if x is a number in the sequence add 2x, 4x+1, and 8x+3 to the sequence. The n-th Tribbinary number is even if the n-th term of the Tribonacci word is a. Respectively, the n-th Tribbinary number is of the form 4x+1 if the n-th term of the Tribonacci word is b, and the n-th Tribbinary number is of the form 8x+3 if the n-th term of the Tribonacci word is c. Every nonnegative integer can be written as the sum of two Tribbinary numbers. Every number has a Tribbinary multiple. - Tanya Khovanova and PRIMES STEP Senior, Aug 30 2022

Crossrefs

Cf. A278038 (binary), A063037, A000073, A014082 (number of 111).
Cf. A004781 (complement).
Cf. A007088; A003796 (no 000), A004745 (no 001), A004746 (no 010), A004744 (no 011), A003754 (no 100), A004742 (no 101), A004743 (no 110).

Programs

  • Haskell
    a003726 n = a003726_list !! (n - 1)
    a003726_list = filter f [0..] where
       f x = x < 7 || (x `mod` 8) < 7 && f (x `div` 2)
    -- Reinhard Zumkeller, Jun 03 2012
    
  • Mathematica
    Select[Range[0, 82], SequenceCount[IntegerDigits[#, 2], {1, 1, 1}] == 0 &] (* Michael De Vlieger, Dec 23 2019 *)
  • PARI
    is(n)=!bitand(bitand(n, n<<1), n<<2) \\ Charles R Greathouse IV, Feb 11 2017

Formula

There are A000073(n+3) terms of this sequence with at most n bits. In particular, a(A000073(n+3)+1) = 2^n. - Charles R Greathouse IV, Oct 22 2021
Sum_{n>=2} 1/a(n) = 9.516857810319139410424631558212354346868048230248717360943194590798113163384... (calculated using Baillie and Schmelzer's kempnerSums.nb, see Links). - Amiram Eldar, Feb 13 2022

A033264 Number of blocks of {1,0} in the binary expansion of n.

Original entry on oeis.org

0, 1, 0, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 2, 1, 2, 2, 3, 2, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2
Offset: 1

Views

Author

Keywords

Comments

Number of i such that d(i) < d(i-1), where Sum_{d(i)*2^i: i=0,1,....,m} is base 2 representation of n.
This is the base-2 down-variation sequence; see A297330. - Clark Kimberling, Jan 18 2017

Crossrefs

a(n) = A005811(n) - ceiling(A005811(n)/2) = A005811(n) - A069010(n).
Equals (A072219(n+1)-1)/2.
Cf. also A175047, A030308.
Essentially the same as A087116.

Programs

  • Haskell
    a033264 = f 0 . a030308_row where
       f c [] = c
       f c (0 : 1 : bs) = f (c + 1) bs
       f c (_ : bs) = f c bs
    -- Reinhard Zumkeller, Feb 20 2014, Jun 17 2012
    
  • Maple
    f:= proc(n) option remember; local k;
    k:= n mod 4;
    if k = 2 then procname((n-2)/4) + 1
    elif k = 3 then procname((n-3)/4)
    else procname((n-k)/2)
    fi
    end proc:
    f(1):= 0: f(0):= q:
    seq(f(i),i=1..100); # Robert Israel, Aug 31 2015
  • Mathematica
    Table[Count[Partition[IntegerDigits[n, 2], 2, 1], {1, 0}], {n, 102}] (* Michael De Vlieger, Aug 31 2015, after Robert G. Wilson v at A014081 *)
    Table[SequenceCount[IntegerDigits[n,2],{1,0}],{n,110}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 26 2017 *)
  • PARI
    a(n) = { hammingweight(bitand(n>>1, bitneg(n))) }; \\ Gheorghe Coserea, Aug 30 2015
    
  • Python
    def A033264(n): return ((n>>1)&~n).bit_count() # Chai Wah Wu, Jun 25 2025

Formula

G.f.: 1/(1-x) * Sum_(k>=0, t^2/(1+t)/(1+t^2), t=x^2^k). - Ralf Stephan, Sep 10 2003
a(n) = A069010(n) - (n mod 2). - Ralf Stephan, Sep 10 2003
a(4n) = a(4n+1) = a(2n), a(4n+2) = a(n)+1, a(4n+3) = a(n). - Ralf Stephan, Aug 20 2003
a(n) = A087116(n) for n > 0, since strings of 0's alternate with strings of 1's, which end in (1,0). - Jonathan Sondow, Jan 17 2016
Sum_{n>=1} a(n)/(n*(n+1)) = Pi/4 - log(2)/2 (A196521) (Allouche and Shallit, 1990). - Amiram Eldar, Jun 01 2021

A037800 Number of occurrences of 01 in the binary expansion of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 3, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1
Offset: 0

Views

Author

Keywords

Comments

Number of i such that d(i)>d(i-1), where Sum{d(i)*2^i: i=0,1,...,m} is base 2 representation of n.
This is the base-2 up-variation sequence; see A297330. - Clark Kimberling, Jan 18 2017

Crossrefs

Programs

  • Haskell
    a037800 = f 0 . a030308_row where
       f c [_]          = c
       f c (1 : 0 : bs) = f (c + 1) bs
       f c (_ : bs)     = f c bs
    -- Reinhard Zumkeller, Feb 20 2014
    
  • Mathematica
    Table[SequenceCount[IntegerDigits[n,2],{0,1}],{n,0,120}] (* Harvey P. Dale, Aug 10 2023 *)
  • PARI
    a(n) = { if(n == 0, 0, -1 + hammingweight(bitnegimply(n, n>>1))) };  \\ Gheorghe Coserea, Aug 31 2015

Formula

a(2n) = a(n), a(2n+1) = a(n) + [n is even]. - Ralf Stephan, Aug 21 2003
G.f.: 1/(1-x) * Sum_{k>=0} t^5/(1+t)/(1+t^2) where t=x^2^k. - Ralf Stephan, Sep 10 2003
a(n) = A069010(n) - 1, n>0. - Ralf Stephan, Sep 10 2003
Sum_{n>=1} a(n)/(n*(n+1)) = log(2)/2 + Pi/4 - 1 = A231902 - 1 (Allouche and Shallit, 1990). - Amiram Eldar, Jun 01 2021

A056978 Number of blocks of {1, 0, 0} in binary expansion of n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1
Offset: 1

Views

Author

Keywords

Comments

a(n) = A213629(n,4) for n > 3. - Reinhard Zumkeller, Jun 17 2012

Crossrefs

Programs

  • Haskell
    import Data.List (tails, isPrefixOf)
    a056978 = sum . map (fromEnum . ([0,0,1] `isPrefixOf`)) .
                        tails . a030308_row
    -- Reinhard Zumkeller, Jun 17 2012
    
  • Mathematica
    a[1] = a[2] = 0; a[n_] := a[n] = If[OddQ[n], a[(n-1)/2], a[n/2] + Boole[Mod[n/2, 4] == 2]]; Table[a[n], {n, 1, 102}] (* Jean-François Alcover, Oct 22 2012, after Ralf Stephan *)
    Table[SequenceCount[IntegerDigits[n,2],{1,0,0}],{n,120}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Dec 01 2016 *)
  • PARI
    a(n) = hammingweight(bitnegimply(n>>2, bitor(n>>1, n)));  \\ Gheorghe Coserea, Sep 08 2015

Formula

a(2n) = a(n) + [n congruent to 2 mod 4], a(2n+1) = a(n). - Ralf Stephan, Aug 22 2003

A056979 Number of blocks of {1, 0, 1} in binary expansion of n.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 2, 2, 1, 2, 1, 1, 0, 0, 0, 0, 1, 2, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 2, 3, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0, 0, 0, 0, 0, 1, 0
Offset: 1

Views

Author

Keywords

Comments

a(n) = A213629(n,5) for n > 4. - Reinhard Zumkeller, Jun 17 2012

Crossrefs

Programs

  • Haskell
    import Data.List (tails, isPrefixOf)
    a056979 = sum . map (fromEnum . ([1,0,1] `isPrefixOf`)) .
                        tails . a030308_row
    -- Reinhard Zumkeller, Jun 17 2012
    
  • Mathematica
    a[1] = a[2] = 0; a[n_] := a[n] = If[EvenQ[n], a[n/2], a[(n - 1)/2] + Boole[Mod[(n - 1)/2, 4] == 2]]; Table[a[n], {n, 1, 102}] (* Jean-François Alcover, Oct 22 2012, after Ralf Stephan *)
  • PARI
    a(n) = hammingweight(bitnegimply(bitand(n, n>>2), n>>1));
    vector(102, i, a(i))  \\ Gheorghe Coserea, Sep 17 2015

Formula

a(2n) = a(n), a(2n+1) = a(n) + [n congruent to 2 mod 4]. - Ralf Stephan, Aug 22 2003

A056980 Number of blocks of {1, 1, 0} in binary expansion of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (tails, isPrefixOf)
    a056980 = sum . map (fromEnum . ([0,1,1] `isPrefixOf`)) .
                        tails . a030308_row
    -- Reinhard Zumkeller, Jun 17 2012
    
  • Mathematica
    a[1] = a[2] = 0; a[n_] := a[n] = If[OddQ[n], a[(n - 1)/2], a[n/2] + Boole[Mod[n/2, 4] == 3]]; Table[a[n], {n, 1, 102}] (* Jean-François Alcover, Oct 22 2012, after Ralf Stephan *)
  • PARI
    a(n) = hammingweight(bitnegimply(bitand(n>>1, n>>2), n));
    vector(102, i, a(i))  \\  Gheorghe Coserea, Sep 07 2015

Formula

a(2n) = a(n) + [n congruent to 3 mod 4], a(2n+1) = a(n). - Ralf Stephan, Aug 22 2003
a(n) = A213629(n,6) for n > 5. - Reinhard Zumkeller, Jun 17 2012

A213629 In binary representation: T(n,k) = number of (possibly overlapping) occurrences of k in n, triangle read by rows, 1<=k<=n.

Original entry on oeis.org

1, 1, 1, 2, 0, 1, 1, 1, 0, 1, 2, 1, 0, 0, 1, 2, 1, 1, 0, 0, 1, 3, 0, 2, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0, 0, 1, 2, 2, 0, 0, 1, 0, 0, 0, 0, 1, 3, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 3, 1, 1, 0, 1, 1, 0, 0
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 17 2012

Keywords

Comments

The definition is based on the definition of pattern functions in the paper of Allouche and Shallit;
sum of n-th row = A029931(n);
T(n,1) = A000120(n);
T(n,2) = A033264(n) for n > 1;
T(n,3) = A014081(n) for n > 2;
T(n,4) = A056978(n) for n > 3;
T(n,5) = A056979(n) for n > 4;
T(n,6) = A056980(n) for n > 5;
T(n,7) = A014082(n) for n > 6;
T(n,k) = 0 for k with floor(n/2) < k < n;
T(n,n) = 1;
A122953(n) = Sum_{k=1..n} A057427(T(n,k));
A005811(n) = T(n,1) + T(n,2) - T(n,3);
A007302(n) = A000120(n) - sum (A213629(n,A136412(k))).

Examples

			The triangle begins:
.   1:                        1
.   2:                      1   1
.   3:                    2   0   1
.   4:                  1   1   0   1
.   5:                2   1   0   0   1
.   6:              2   1   1   0   0   1
.   7:            3   0   2   0   0   0   1
.   8:          1   1   0   1   0   0   0   1
.   9:        2   1   0   1   0   0   0   0   1
.  10:      2   2   0   0   1   0   0   0   0   1
.  11:    3   1   1   0   1   0   0   0   0   0   1
.  12:  2   1   1   1   0   1   0   0   0   0   0   1.
		

Crossrefs

Programs

  • Haskell
    import Data.List (inits, tails, isPrefixOf)
    a213629 n k = a213629_tabl !! (n-1) !! (k-1)
    a213629_row n = a213629_tabl !! (n-1)
    a213629_tabl = map f $ tail $ inits $ tail $ map reverse a030308_tabf where
       f xss = map (\xs ->
               sum $ map (fromEnum . (xs `isPrefixOf`)) $ tails $ last xss) xss
  • Mathematica
    t[n_, k_] := (idn = IntegerDigits[n, 2]; idk = IntegerDigits[k, 2]; ln = Length[idn]; lk = Length[idk]; For[cnt = 0; i = 1, i <= ln - lk + 1, i++, If[idn[[i ;; i + lk - 1]] == idk, cnt++]]; cnt); Table[t[n, k], {n, 1, 14}, {k, 1, n}] // Flatten (* Jean-François Alcover, Oct 22 2012 *)

A056974 Number of blocks of {0, 0, 0} in the binary expansion of n.

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Comments

Overlaps count. For example, 64 in binary is 1000000, which means that a(64) = 4, not 2. - Harvey P. Dale, Jan 10 2016

Crossrefs

Programs

  • 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 *)
  • 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

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

A056976 Number of blocks of {0, 1, 0} in the binary expansion of n.

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • 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 *)
  • 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)
    };
    vector(102, i, a(i))  \\ Gheorghe Coserea, Sep 17 2015

Formula

a(2n) = a(n) + [n>1 and n congruent to 1 mod 4], a(2n+1) = a(n). - Ralf Stephan, Aug 22 2003
Showing 1-10 of 15 results. Next