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 10 results.

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

A014082 Number of occurrences of '111' in binary expansion of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

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

Crossrefs

Programs

  • Haskell
    import Data.List (tails, isPrefixOf)
    a014082 = sum . map (fromEnum . ([1,1,1] `isPrefixOf`)) .
                        tails . a030308_row
    -- Reinhard Zumkeller, Jun 17 2012
    
  • Maple
    See A014081.
    f:= proc(n) option remember;
      if n::even then procname(n/2)
      elif n mod 8 = 7 then 1 + procname((n-1)/2)
      else procname((n-1)/2)
    fi
    end proc:
    f(0):= 0:
    map(f, [$0..1000]); # Robert Israel, Sep 11 2015
  • Mathematica
    f[n_] := Count[ Partition[ IntegerDigits[n, 2], 3, 1], {1, 1, 1}]; Table[f@n, {n, 0, 104}] (* Robert G. Wilson v, Apr 02 2009 *)
    a[0] = a[1] = 0; a[n_] := a[n] = If[EvenQ[n], a[n/2], a[(n - 1)/2] + Boole[Mod[(n - 1)/2, 4] == 3]]; Table[a[n], {n, 0, 104}] (* Jean-François Alcover, Oct 22 2012, after Ralf Stephan *)
    Table[SequenceCount[IntegerDigits[n,2],{1,1,1},Overlaps->True],{n,0,110}] (* Harvey P. Dale, Mar 05 2023 *)
  • PARI
    a(n) = hammingweight(bitand(n, bitand(n>>1, n>>2))); \\ Gheorghe Coserea, Aug 30 2015

Formula

a(2n) = a(n), a(2n+1) = a(n) + [n congruent to 3 mod 4]. - Ralf Stephan, Aug 21 2003
G.f.: 1/(1-x) * Sum_{k>=0} t^7(1-t)/(1-t^8), where t=x^2^k. - Ralf Stephan, Sep 08 2003

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

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

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

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1
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, 1}], {n, 1, 102} ] (* Jean-François Alcover, Oct 23 2012 *)
    Table[SequenceCount[IntegerDigits[n,2],{0,1,1}],{n,120}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 03 2019 *)
  • PARI
    a(n) = {
      if (n < 11, return(0));
      my(k = logint(n,2) - 1);
      hammingweight(bitnegimply(bitand(n>>1, n), n>>2)) - bittest(n,k)
    };
    vector(102, i, a(i))  \\ Gheorghe Coserea, Sep 17 2015

Formula

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

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

Original entry on oeis.org

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

Views

Author

Keywords

Crossrefs

Cf. A007088 (binary expansion).
Other block counts: A014082, A056974, A056976, A056977, A056978, A056979, A056980.

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, 1}], {n, 1, 102} ] (* Jean-François Alcover, Oct 23 2012 *)
    Table[SequenceCount[IntegerDigits[n,2],{0,0,1}],{n,110}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Apr 26 2019 *)

Formula

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