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-3 of 3 results.

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

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

A239904 a(n) = n - wt(n) + (number of times 11 appears in binary expansion of n).

Original entry on oeis.org

0, 0, 1, 2, 3, 3, 5, 6, 7, 7, 8, 9, 11, 11, 13, 14, 15, 15, 16, 17, 18, 18, 20, 21, 23, 23, 24, 25, 27, 27, 29, 30, 31, 31, 32, 33, 34, 34, 36, 37, 38, 38, 39, 40, 42, 42, 44, 45, 47, 47, 48, 49, 50, 50, 52, 53, 55, 55, 56, 57, 59, 59, 61, 62, 63, 63, 64, 65, 66, 66, 68, 69, 70, 70, 71, 72, 74, 74, 76
Offset: 0

Views

Author

N. J. A. Sloane, Apr 06 2014

Keywords

Comments

This is G_{2, 1/4}(n) in Prodinger's notation.

Crossrefs

Programs

  • Maple
    A000120 := proc(n) add(i, i=convert(n, base, 2)) end:
    # 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-A000120(n)+cn(n,2), n=0..100)];
  • Mathematica
    cn[n_, k_] := Count[Partition[IntegerDigits[n, 2], k, 1], Table[1, {k}]]; Table[n - DigitCount[n, 2, 1] + cn[n, 2], {n, 0, 78}] (* Michael De Vlieger, Sep 18 2015 *)
  • PARI
    a(n) = n - hammingweight(n) + hammingweight(bitand(n, n>>1));
    vector(79, i, a(i-1))  \\ Gheorghe Coserea, Sep 24 2015
    
  • Python
    def A239904(n): return n-n.bit_count()+(n&(n>>1)).bit_count() # Chai Wah Wu, Feb 12 2023

Formula

a(n) = n - A000120(n) + A014081(n).
Showing 1-3 of 3 results.