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.

A330036 The length of the largest run of 0's in the binary expansion of n + the length of the largest run of 1's in the binary expansion of n.

Original entry on oeis.org

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

Views

Author

Joshua Oliver, Nov 27 2019

Keywords

Comments

All numbers appear in this sequence. The number of 1's in the n-th Mersenne number (A000225) is n and the number of 0's in the n-th Mersenne number is 0. 0+n=n. See formula.

Examples

			   n [binary n ]  A087117(n) + A038374(n) = a(n)
   0 [       0 ]  1          + 0          = 1
   1 [       1 ]  0          + 1          = 1
   2 [     1 0 ]  1          + 1          = 2
   3 [     1 1 ]  0          + 2          = 2
   4 [   1 0 0 ]  2          + 1          = 3
   5 [   1 0 1 ]  1          + 1          = 2
   6 [   1 1 0 ]  1          + 2          = 3
   7 [   1 1 1 ]  0          + 3          = 3
   8 [ 1 0 0 0 ]  3          + 1          = 4
   9 [ 1 0 0 1 ]  2          + 1          = 3
  10 [ 1 0 1 0 ]  1          + 1          = 2
  11 [ 1 0 1 1 ]  1          + 2          = 3
  12 [ 1 1 0 0 ]  2          + 2          = 4
  13 [ 1 1 0 1 ]  1          + 2          = 3
  14 [ 1 1 1 0 ]  1          + 3          = 4
  15 [ 1 1 1 1 ]  0          + 4          = 4
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L;
      L:= convert(n,base,2);
      max(map(nops,[ListTools:-Split(`=`,L,1)]))+max(map(nops,[ListTools:-Split(`=`,L,0)]))
    end proc:
    map(f, [$0..100]); # Robert Israel, Apr 06 2020
  • Mathematica
    Table[Sum[Max[Differences[Position[Flatten@{k,IntegerDigits[n,2],k},k]]],{k,0,1}]-2,{n,0,82}]

Formula

a(n) = A087117(n) + A038374(n).
a(A000225(n)) = n for n > 0.