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.

Previous Showing 11-15 of 15 results.

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

A239906 Let cn(n,k) denote the number of times 11..1 (k 1's) appears in the binary representation of n; a(n) = n - cn(n,1) + cn(n,2) - cn(n,3).

Original entry on oeis.org

0, 0, 1, 2, 3, 3, 5, 5, 7, 7, 8, 9, 11, 11, 12, 12, 15, 15, 16, 17, 18, 18, 20, 20, 23, 23, 24, 25, 26, 26, 27, 27, 31, 31, 32, 33, 34, 34, 36, 36, 38, 38, 39, 40, 42, 42, 43, 43, 47, 47, 48, 49, 50, 50, 52, 52, 54, 54, 55, 56, 57, 57, 58, 58, 63, 63, 64, 65, 66, 66, 68, 68, 70, 70, 71, 72, 74, 74
Offset: 0

Views

Author

N. J. A. Sloane, Apr 07 2014

Keywords

Crossrefs

Programs

  • Maple
    # From A014081:
    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;
    [seq(n-cn(n,1)+cn(n,2)-cn(n,3), n=0..100)];
  • Mathematica
    cn[n_, k_] := Count[Partition[IntegerDigits[n, 2], k, 1], Table[1, {k}]]; Table[n - Sum[cn[n, i], {i, 1, 3, 2}] + cn[n, 2], {n, 0, 77}] (* Michael De Vlieger, Sep 18 2015 *)
  • PARI
    a(n) = {
        my(x = bitand(n, n>>1), wt = k->hammingweight(k));
        n - wt(n) + wt(x) - wt(bitand(x, n>>2));
    };
    vector(78, i, a(i-1))  \\ Gheorghe Coserea, Sep 24 2015

A239907 Let cn(n,k) denote the number of times 11..1 (k 1's) appears in the binary representation of n; a(n) = n - cn(n,1) + cn(n,2) - cn(n,3) + cn(n,4) - ... .

Original entry on oeis.org

0, 0, 1, 2, 3, 3, 5, 5, 7, 7, 8, 9, 11, 11, 12, 13, 15, 15, 16, 17, 18, 18, 20, 20, 23, 23, 24, 25, 26, 26, 28, 28, 31, 31, 32, 33, 34, 34, 36, 36, 38, 38, 39, 40, 42, 42, 43, 44, 47, 47, 48, 49, 50, 50, 52, 52, 54, 54, 55, 56, 58, 58, 59, 60, 63, 63, 64, 65, 66, 66, 68, 68, 70, 70, 71, 72, 74, 74, 75
Offset: 0

Views

Author

N. J. A. Sloane, Apr 07 2014

Keywords

Crossrefs

Programs

  • Maple
    # From A014081:
    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;
    g:=n->add((-1)^i*cn(n,i),i=1..10); # assumes n < 1023
    [seq(n+g(n), n=0..100)];
  • Mathematica
    cn[n_, k_] := Count[Partition[IntegerDigits[n, 2], k, 1], Table[1, {k}]]; Table[n - Sum[cn[n, i], {i, 1, IntegerLength[n, 2], 2}] + Sum[cn[n, i], {i, 2, IntegerLength[n, 2], 2}], {n, 0, 78}] (* Michael De Vlieger, Sep 18 2015 *)
  • PARI
    binruns(n) = {
      if (n == 0, return([1, 0]));
      my(bag = List(), v=0);
      while(n != 0,
            v = valuation(n,2); listput(bag, v); n >>= v; n++;
            v = valuation(n,2); listput(bag, v); n >>= v; n--);
      return(Vec(bag));
    };
    a(n) = {
      my(v = binruns(n));
      n - sum(i = 1, #v, if (i%2 == 0, (v[i] + 1)\2, 0))
    };
    vector(79, i, a(i-1))  \\ Gheorghe Coserea, Sep 18 2015

Formula

Conjecture: a(n) = n - A329320(n) for n >= 0 (noticed by Sequence Machine). - Mikhail Kurkov, Oct 13 2021

A014083 Occurrences of '1111' in binary expansion of n.

Original entry on oeis.org

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

Views

Author

Keywords

Examples

			a(63) = 3 as 63 = 111111 in binary and 1111 occurs three times (different occurrences may overlap). - _Antti Karttunen_, Jul 24 2017
		

Crossrefs

Programs

  • Maple
    See A014081.
  • Mathematica
    Table[SequenceCount[IntegerDigits[n,2],{1,1,1,1},Overlaps->True],{n,0,100}] (* The program uses the SequenceCount function from Mathematica version 10 *) (* Harvey P. Dale, Sep 25 2015 *)
  • PARI
    u1111(n)=my(v=binary(n)); sum(k=1,#v-3, v[k]&&v[k+1]&&v[k+2]&&v[k+3])
    
  • PARI
    a(n)=my(s,t); while(n, n>>=valuation(n,2); t=valuation(n+1,2); s+=max(t-3, 0); n>>=t); s \\ Charles R Greathouse IV, Jan 21 2016

Formula

a(2n) = a(n), a(2n+1) = a(n) + [n congruent to 7 mod 8]. - Ralf Stephan, Aug 21 2003
G.f.: 1/(1-x) * sum(k>=0, t^15(1-t)/(1-t^16), t=x^2^k). - Ralf Stephan, Sep 08 2003
a(n) <= log_2(n+1) - 3 for n >= 7. - Charles R Greathouse IV, Jan 21 2016

Extensions

Term a(0)=0 prepended and more terms from Antti Karttunen, Jul 24 2017
Previous Showing 11-15 of 15 results.