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.

A246588 Run Length Transform of S(n) = wt(n) = 0,1,1,2,1,2,2,3,1,... (cf. A000120).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Sep 05 2014

Keywords

Comments

The Run Length Transform of a sequence {S(n), n>=0} is defined to be the sequence {T(n), n>=0} given by T(n) = Product_i S(i), where i runs through the lengths of runs of 1's in the binary expansion of n. E.g. 19 is 10011 in binary, which has two runs of 1's, of lengths 1 and 2. So T(19) = S(1)*S(2). T(0)=1 (the empty product).

Crossrefs

Cf. A000120.
Run Length Transforms of other sequences: A071053, A227349, A246595, A246596, A246660, A246661, A246674.

Programs

  • Haskell
    import Data.List (group)
    a246588 = product . map (a000120 . length) .
              filter ((== 1) . head) . group . a030308_row
    -- Reinhard Zumkeller, Feb 13 2015, Sep 05 2014
    
  • Maple
    A000120 := proc(n) local w, m, i; w := 0; m :=n; while m > 0 do i := m mod 2; w := w+i; m := (m-i)/2; od; w; end: wt := A000120;
    ans:=[];
    for n from 0 to 100 do lis:=[]; t1:=convert(n, base, 2); L1:=nops(t1); out1:=1; c:=0;
    for i from 1 to L1 do
       if out1 = 1 and t1[i] = 1 then out1:=0; c:=c+1;
       elif out1 = 0 and t1[i] = 1 then c:=c+1;
       elif out1 = 1 and t1[i] = 0 then c:=c;
       elif out1 = 0 and t1[i] = 0 then lis:=[c, op(lis)]; out1:=1; c:=0;
       fi;
       if i = L1 and c>0 then lis:=[c, op(lis)]; fi;
                       od:
    a:=mul(wt(i), i in lis);
    ans:=[op(ans), a];
    od:
    ans;
  • Mathematica
    f[n_] := DigitCount[n, 2, 1]; Table[Times @@ (f[Length[#]]&)  /@ Select[ Split[ IntegerDigits[n, 2]], #[[1]] == 1&], {n, 0, 100}] (* Jean-François Alcover, Jul 11 2017 *)
  • Python
    from operator import mul
    from functools import reduce
    from re import split
    def A246588(n):
        return reduce(mul,(bin(len(d)).count('1') for d in split('0+',bin(n)[2:]) if d)) if n > 0 else 1 # Chai Wah Wu, Sep 07 2014
    
  • Sage
    # uses[RLT from A246660]
    A246588_list = lambda len: RLT(lambda n: sum(Integer(n).digits(2)), len)
    A246588_list(88) # Peter Luschny, Sep 07 2014