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

A165413 a(n) is the number of distinct lengths of runs in the binary representation of n.

Original entry on oeis.org

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

Views

Author

Leroy Quet, Sep 17 2009

Keywords

Comments

Least k whose value is n: 1, 4, 35, 536, 16775, 1060976, ..., = A165933. - Robert G. Wilson v, Sep 30 2009

Examples

			92 in binary is 1011100. There is a run of one 1, followed by a run of one 0, then a run of three 1's, then finally a run of two 0's. The run lengths are therefore (1,1,3,2). The distinct values of these run lengths are (1,3,2). Since there are 3 distinct values, then a(92) = 3.
		

Crossrefs

Cf. A140690 (locations of 1's), A165933 (locations of new highs).

Programs

  • Haskell
    import Data.List (group, nub)
    a165413 = length . nub . map length . group . a030308_row
    -- Reinhard Zumkeller, Mar 02 2013
    
  • Mathematica
    f[n_] := Length@ Union@ Map[ Length, Split@ IntegerDigits[n, 2]]; Array[f, 105] (* Robert G. Wilson v, Sep 30 2009 *)
  • 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) = #Set(select(k->k, binruns(n)));
    vector(105, i, a(i))  \\ Gheorghe Coserea, Sep 17 2015
    
  • Python
    from itertools import groupby
    def a(n): return len(set([len(list(g)) for k, g in groupby(bin(n)[2:])]))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jan 04 2021

Formula

a(n) = 1 for n in A140690. - Robert G. Wilson v, Sep 30 2009

Extensions

More terms from Robert G. Wilson v, Sep 30 2009

A350952 The smallest number whose binary expansion has exactly n distinct runs.

Original entry on oeis.org

0, 1, 2, 11, 38, 311, 2254, 36079, 549790, 17593311, 549687102, 35179974591, 2225029922430, 284803830071167, 36240869367020798, 9277662557957324543, 2368116566113212692990, 1212475681849964898811391, 619877748107024946567312382, 634754814061593545284927880191
Offset: 0

Views

Author

Gus Wiseman, Feb 14 2022

Keywords

Comments

Positions of first appearances in A297770 (with offset 0).
The binary expansion of terms for n > 0 starts with 1, then floor(n/2) 0's, then alternates runs of increasing numbers of 1's, and decreasing numbers of 0's; see Python code. Thus, for n even, terms have n*(n/2+1)/2 binary digits, and for n odd, ((n+1) + (n-1)*((n-1)/2+1))/2 binary digits. - Michael S. Branicky, Feb 14 2022

Examples

			The terms and their binary expansions begin:
       0:                   ()
       1:                    1
       2:                   10
      11:                 1011
      38:               100110
     311:            100110111
    2254:         100011001110
   36079:     1000110011101111
  549790: 10000110001110011110
For example, 311 has binary expansion 100110111 with 5 distinct runs: 1, 00, 11, 0, 111.
		

Crossrefs

Runs in binary expansion are counted by A005811, distinct A297770.
The version for run-lengths instead of runs is A165933, for A165413.
Subset of A175413 (binary expansion has distinct runs), for lengths A044813.
The version for standard compositions is A351015.
A000120 counts binary weight.
A011782 counts integer compositions.
A242882 counts compositions with distinct multiplicities.
A318928 gives runs-resistance of binary expansion.
A334028 counts distinct parts in standard compositions.
A351014 counts distinct runs in standard compositions.
Counting words with all distinct runs:
- A351013 = compositions, for run-lengths A329739, ranked by A351290.
- A351016 = binary words, for run-lengths A351017.
- A351018 = binary expansions, for run-lengths A032020.
- A351200 = patterns, for run-lengths A351292.
- A351202 = permutations of prime factors.

Programs

  • Mathematica
    q=Table[Length[Union[Split[If[n==0,{},IntegerDigits[n,2]]]]],{n,0,1000}];Table[Position[q,i][[1,1]]-1,{i,Union[q]}]
  • PARI
    a(n)={my(t=0); for(k=1, (n+1)\2, t=((t<Andrew Howroyd, Feb 15 2022
  • Python
    def a(n): # returns term by construction
        if n == 0: return 0
        q, r = divmod(n, 2)
        if r == 0:
            s = "".join("1"*i + "0"*(q-i+1) for i in range(1, q+1))
            assert len(s) == n*(n//2+1)//2
        else:
            s = "1" + "".join("0"*(q-i+2) + "1"*i for i in range(2, q+2))
            assert len(s) == ((n+1) + (n-1)*((n-1)//2+1))//2
        return int(s, 2)
    print([a(n) for n in range(20)]) # Michael S. Branicky, Feb 14 2022
    

Extensions

a(9)-a(19) from Michael S. Branicky, Feb 14 2022

A353929 Number of distinct sums of runs (of 0's or 1's) in the binary expansion of n.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jun 26 2022

Keywords

Comments

Assuming the binary digits are not all 1, this is one more than the number of different lengths of runs of 1's in the binary expansion of n.

Examples

			The binary expansion of 183 is (1,0,1,1,0,1,1,1), with runs (1), (0), (1,1), (0), (1,1,1), with sums 1, 0, 2, 0, 3, of which four are distinct, so a(183) = 4.
		

Crossrefs

For lengths of all runs we have A165413, firsts A165933.
Numbers whose binary expansion has distinct runs are A175413.
For runs instead of run-sums we have A297770, firsts A350952.
For prime indices we have A353835, weak A353861, firsts A006939.
For standard compositions we have A353849, firsts A246534.
Positions of first appearances are A353930.
A005811 counts runs in binary expansion.
A044813 lists numbers with distinct run-lengths in binary expansion.
A318928 gives runs-resistance of binary expansion.
A351014 counts distinct runs in standard compositions.

Programs

  • Mathematica
    Table[Length[Union[Total/@Split[IntegerDigits[n,2]]]],{n,0,100}]
  • Python
    from itertools import groupby
    def A353929(n): return len(set(sum(map(int,y[1])) for y in groupby(bin(n)[2:]))) # Chai Wah Wu, Jun 26 2022

A353930 Smallest number whose binary expansion has n distinct run-sums.

Original entry on oeis.org

1, 2, 11, 183, 5871, 375775, 48099263, 12313411455, 6304466665215, 6455773865180671, 13221424875890015231, 54154956291645502388223, 443637401941159955564326911, 7268555193403964711965932118015, 238176016577461115681699663643131903, 15609103422420491677315869156516292427775
Offset: 1

Views

Author

Gus Wiseman, Jun 07 2022

Keywords

Comments

Every sequence can be uniquely split into a sequence of non-overlapping runs. For example, the runs of (2,2,1,1,1,3,2,2) are ((2,2),(1,1,1),(3),(2,2)), with sums (4,3,3,4).

Examples

			The terms, binary expansions, and standard compositions begin:
       1:                    1  (1)
       2:                   10  (2)
      11:                 1011  (2,1,1)
     183:             10110111  (2,1,2,1,1,1)
    5871:        1011011101111  (2,1,2,1,1,2,1,1,1,1)
  375775:  1011011101111011111  (2,1,2,1,1,2,1,1,1,2,1,1,1,1,1)
		

Crossrefs

Essentially the same as A215203.
For prime indices instead of binary expansion we have A006939.
For lengths instead of sums of runs we have A165933 = firsts in A165413.
Numbers whose binary expansion has all distinct runs are A175413.
For standard compositions we have A246534, firsts of A353849.
For runs instead of run-sums we have A350952, firsts of A297770.
These are the positions of first appearances in A353929.
A005811 counts runs in binary expansion.
A242882 counts compositions with distinct multiplicities.
A318928 gives runs-resistance of binary expansion.
A351014 counts distinct runs in standard compositions.
A353835 counts partitions with all distinct run-sums, weak A353861.
A353864 counts rucksack partitions.

Programs

  • Mathematica
    qe=Table[Length[Union[Total/@Split[IntegerDigits[n,2]]]],{n,1,10000}];
    Table[Position[qe,i][[1,1]],{i,Max@@qe}]
  • PARI
    a(n) = {my(t=1); if(n==2, t<<=1, for(k=3, n, t = (t<Andrew Howroyd, Jan 01 2023

Extensions

Offset corrected and terms a(7) and beyond from Andrew Howroyd, Jan 01 2023
Showing 1-4 of 4 results.