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.

A044813 Positive integers having distinct base-2 run lengths.

Original entry on oeis.org

1, 3, 4, 6, 7, 8, 14, 15, 16, 24, 28, 30, 31, 32, 35, 39, 48, 49, 55, 57, 59, 60, 62, 63, 64, 67, 79, 96, 97, 111, 112, 120, 121, 123, 124, 126, 127, 128, 131, 135, 143, 159, 192, 193, 223, 224, 225, 239, 241, 247, 248, 249, 251, 252, 254, 255, 256, 259, 263
Offset: 1

Views

Author

Keywords

Comments

A005811(a(n)) = A165413(a(n)). - Reinhard Zumkeller, Mar 02 2013
From Emeric Deutsch, Jan 25 2018: (Start)
Also, the indices of the compositions that have distinct parts. For the definition of the index of a composition see A298644. For example, 223 is in the sequence since its binary form is 11011111 and the composition [2,1,5] has distinct parts. 100 is not in the sequence since its binary form is 1100100 and the parts of the composition [2,2,1,2] are not distinct.
The command c(n) from the Maple program yields the composition having index n. (End)

Crossrefs

Programs

  • Haskell
    import Data.List (group, nub)
    a044813 n = a044813_list !! (n-1)
    a044813_list = filter p [1..] where
       p x = nub xs == xs where
             xs = map length $ group $ a030308_row x
    -- Reinhard Zumkeller, Mar 02 2013
    
  • Maple
    Runs := proc (L) local j, r, i, k: j := 1: r[j] := L[1]: for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1: r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc: RunLengths := proc (L) map(nops, Runs(L)) end proc: c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc: A := {}: for n to 300 do if nops(convert(c(n), set)) = nops(c(n)) then A := `union`(A, {n}) else end if end do: A; # most of the Maple program is due to W. Edwin Clark. - Emeric Deutsch, Jan 25 2018
  • Mathematica
    f[n_] := Unequal@@Length/@Split[IntegerDigits[n,2]]; Select[Range[300],f] (* Ray Chandler, Oct 21 2011 *)
  • PARI
    is(n) = {
      my(v = 0, hist = vector(1 + logint(n+1, 2)));
      while(n != 0,
            v = valuation(n, 2); n >>= v; n++;
            hist[v+1]++; if (hist[v+1] >= 2, return(0));
            v = valuation(n, 2); n >>= v; n--;
            hist[v+1]++; if (hist[v+1] >= 2, return(0)));
      return(1);
    };
    seq(n) = {
      my(k = 1, top = 0, v = vector(n));
      while(top < n, if (is(k), v[top++] = k); k++);
      return(v);
    };
    seq(59) \\ Gheorghe Coserea, Nov 02 2015
    
  • Python
    from itertools import groupby
    def ok(n):
      runlengths = [len(list(g)) for k, g in groupby(bin(n)[2:])]
      return len(runlengths) == len(set(runlengths))
    print([i for i in range(1, 264) if ok(i)]) # Michael S. Branicky, Jan 04 2021

Formula

a(Sum_{k=0..n} A032020(k)) = 2^n, for n>1. - Gheorghe Coserea, May 30 2017

Extensions

Extended by Ray Chandler, Oct 21 2011