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-10 of 17 results. Next

A284558 Product / LCM of run lengths in binary representation of n: a(n) = A167489(n) / A284559(n).

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Apr 14 2017

Keywords

Crossrefs

Programs

Formula

a(n) = A167489(n) / A284559(n).

A101211 Triangle read by rows: n-th row is length of run of leftmost 1's, followed by length of run of 0's, followed by length of run of 1's, etc., in the binary representation of n.

Original entry on oeis.org

1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 3, 1, 4, 1, 4, 1, 3, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 3, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 3, 2, 3, 1, 1, 4, 1, 5, 1, 5, 1, 4, 1, 1, 3, 1, 1, 1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 2, 2, 1
Offset: 1

Views

Author

Leroy Quet, Dec 13 2004

Keywords

Comments

Row n has A005811(n) elements. In rows 2^(k-1)..2^k-1 we have all the compositions (ordered partitions) of k. Other orderings of compositions: A066099, A108244, and A124734. - Jason Kimberley, Feb 09 2013
A043276(n) = largest term in n-th row. - Reinhard Zumkeller, Dec 16 2013
From the first comment it follows that we have a bijection between the positive integers and the set of all compositions. - Emeric Deutsch, Jul 11 2017
From Robert Israel, Jan 23 2018: (Start)
If n is even, row 2*n is row n with its last element incremented by 1, and row 2*n+1 is row n with 1 appended.
If n is odd, row 2*n+1 is row n with its last element incremented by 1, and row 2*n is row n with 1 appended. (End)

Examples

			Since 9 is 1001 in binary, the 9th row is 1,2,1.
Since 11 is 1011 in binary, the 11th row is 1,1,2.
Triangle begins:
  1;
  1,1;
  2;
  1,2;
  1,1,1;
  2,1;
  3;
  1,3;
		

Crossrefs

A070939(n) gives the sum of terms in row n, while A167489(n) gives the product of its terms. A090996 gives the first column. A227736 lists the terms of each row in reverse order.
Cf. also A227186.
Cf. A318927 (concatenation of each row), A318926 (concatenations of reversed rows).
Cf. A382255 (Heinz numbers of the rows: Product_k prime(T(n,k))).

Programs

  • Haskell
    import Data.List (group)
    a101211 n k = a101211_tabf !! (n-1) !! (k-1)
    a101211_row n = a101211_tabf !! (n-1)
    a101211_tabf = map (reverse . map length . group) $ tail a030308_tabf
    -- Reinhard Zumkeller, Dec 16 2013
    
  • Maple
    # Maple program due to W. Edwin Clark:
    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: # Row n is obtained with the command c(n). - Emeric Deutsch, Jul 03 2017
    # Maple program due to W. Edwin Clark, yielding the integer ind corresponding to a given composition (the index of the composition):
    ind := proc (x) local X, j, i: X := NULL: for j to nops(x) do if type(j, odd) then X := X, seq(1, i = 1 .. x[j]) end if: if type(j, even) then X := X, seq(0, i = 1 .. x[j]) end if end do: X := [X]: add(X[i]*2^(nops(X)-i), i = 1 .. nops(X)) end proc; # Clearly, ind(c(n))= n. - Emeric Deutsch, Jan 23 2018
  • Mathematica
    Table[Length /@ Split@ IntegerDigits[n, 2], {n, 38}] // Flatten (* Michael De Vlieger, Jul 11 2017 *)
  • PARI
    apply( {A101211_row(n)=Vecrev((n=vecextract([-1..exponent(n)], bitxor(2*n, bitor(n,1))))[^1]-n[^-1])}, [1..19]) \\ replacing older code by M. F. Hasler, Mar 24 2025
  • Python
    from itertools import groupby
    def arow(n): return [len(list(g)) for k, g in groupby(bin(n)[2:])]
    def auptorow(rows):
        alst = []
        for i in range(1, rows+1): alst.extend(arow(i))
        return alst
    print(auptorow(38)) # Michael S. Branicky, Oct 02 2021
    

Formula

a(n) = A227736(A227741(n)) = A227186(A056539(A227737(n)),A227740(n)) - Antti Karttunen, Jul 27 2013

Extensions

More terms from Emeric Deutsch, Apr 12 2005

A227349 Product of lengths of runs of 1-bits in binary representation of n.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 4, 3, 3, 4, 5, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 2, 2, 2, 4, 2, 2, 4, 6, 3, 3, 3, 6, 4, 4, 5, 6, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 4, 3, 3, 4, 5, 2, 2, 2, 4, 2, 2, 4, 6, 2, 2, 2, 4, 4, 4, 6, 8, 3, 3, 3, 6, 3, 3, 6, 9, 4
Offset: 0

Views

Author

Antti Karttunen, Jul 08 2013

Keywords

Comments

This is the Run Length Transform of S(n) = {0, 1, 2, 3, 4, 5, 6, ...}. 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). - N. J. A. Sloane, Sep 05 2014
Like all run length transforms also this sequence satisfies for all i, j: A278222(i) = A278222(j) => a(i) = a(j). - Antti Karttunen, Apr 14 2017

Examples

			a(0) = 1, as zero has no runs of 1's, and an empty product is 1.
a(1) = 1, as 1 is "1" in binary, and the length of that only 1-run is 1.
a(2) = 1, as 2 is "10" in binary, and again there is only one run of 1-bits, of length 1.
a(3) = 2, as 3 is "11" in binary, and there is one run of two 1-bits.
a(55) = 6, as 55 is "110111" in binary, and 2 * 3 = 6.
a(119) = 9, as 119 is "1110111" in binary, and 3 * 3 = 9.
From _Omar E. Pol_, Feb 10 2015: (Start)
Written as an irregular triangle in which row lengths is A011782:
  1;
  1;
  1,2;
  1,1,2,3;
  1,1,1,2,2,2,3,4;
  1,1,1,2,1,1,2,3,2,2,2,4,3,3,4,5;
  1,1,1,2,1,1,2,3,1,1,1,2,2,2,3,4,2,2,2,4,2,2,4,6,3,3,3,6,4,4,5,6;
  ...
Right border gives A028310: 1 together with the positive integers. (End)
From _Omar E. Pol_, Mar 19 2015: (Start)
Also, the sequence can be written as an irregular tetrahedron T(s, r, k) as shown below:
  1;
  ..
  1;
  ..
  1;
  2;
  ....
  1,1;
  2;
  3;
  ........
  1,1,1,2;
  2,2;
  3;
  4;
  ................
  1,1,1,2,1,1,2,3;
  2,2,2,4;
  3,3;
  4;
  5;
  ................................
  1,1,1,2,1,1,2,3,1,1,1,2,2,2,3,4;
  2,2,2,4,2,2,4,6;
  3,3,3,6;
  4,4;
  5;
  6;
  ...
Apart from the initial 1, we have that T(s, r, k) = T(s+1, r, k). (End)
		

Crossrefs

Cf. A003714 (positions of ones), A005361, A005940.
Cf. A000120 (sum of lengths of runs of 1-bits), A167489, A227350, A227193, A278222, A245562, A284562, A284569, A283972, A284582, A284583.
Run Length Transforms of other sequences: A246588, A246595, A246596, A246660, A246661, A246674.
Differs from similar A284580 for the first time at n=119, where a(119) = 9, while A284580(119) = 5.

Programs

  • Maple
    a:= proc(n) local i, m, r; m, r:= n, 1;
          while m>0 do
            while irem(m, 2, 'h')=0 do m:=h od;
            for i from 0 while irem(m, 2, 'h')=1 do m:=h od;
            r:= r*i
          od; r
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Jul 11 2013
    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(i, i in lis);
    ans:=[op(ans), a];
    od:
    ans;  # N. J. A. Sloane, Sep 05 2014
  • Mathematica
    onBitRunLenProd[n_] := Times @@ Length /@ Select[Split @ IntegerDigits[n, 2], #[[1]] == 1 & ]; Array[onBitRunLenProd, 100, 0] (* Jean-François Alcover, Mar 02 2016 *)
  • Python
    from operator import mul
    from functools import reduce
    from re import split
    def A227349(n):
        return reduce(mul, (len(d) 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]
    A227349_list = lambda len: RLT(lambda n: n, len)
    A227349_list(88) # Peter Luschny, Sep 07 2014
    
  • Scheme
    (define (A227349 n) (apply * (bisect (reverse (binexp->runcount1list n)) (- 1 (modulo n 2)))))
    (define (bisect lista parity) (let loop ((lista lista) (i 0) (z (list))) (cond ((null? lista) (reverse! z)) ((eq? i parity) (loop (cdr lista) (modulo (1+ i) 2) (cons (car lista) z))) (else (loop (cdr lista) (modulo (1+ i) 2) z)))))
    (define (binexp->runcount1list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2)) (loop (floor->exact (/ n 2)) (cons count rc) 1 (modulo n 2)))))))

Formula

A167489(n) = a(n) * A227350(n).
A227193(n) = a(n) - A227350(n).
a(n) = Product_{i in row n of table A245562} i. - N. J. A. Sloane, Aug 10 2014
From Antti Karttunen, Apr 14 2017: (Start)
a(n) = A005361(A005940(1+n)).
a(n) = A284562(n) * A284569(n).
A283972(n) = n - a(n).
(End)
a(4n+1) = a(2n) = a(n). If n is odd, then a(4n+3) = 2*a(2n+1)-a(n). If n is even, then a(4n+3) = 2*a(2n+1) = 2*a(n/2). - Chai Wah Wu, Jul 17 2025

Extensions

Data section extended up to term a(120) by Antti Karttunen, Apr 14 2017

A227736 Irregular table read by rows: the first entry of n-th row is length of run of rightmost identical bits (either 0 or 1, equal to n mod 2), followed by length of the next run of bits, etc., in the binary representation of n, when scanned from the least significant to the most significant end.

Original entry on oeis.org

1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 2, 3, 3, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 3, 4, 4, 1, 1, 3, 1, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 3, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 2, 3, 1, 1, 3, 1, 4, 5, 5, 1, 1, 4, 1, 1, 1, 3, 1
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Comments

Row n has A005811(n) terms. In rows 2^(k-1)..2^k-1 we have all the compositions (ordered partitions) of k. Other orderings of compositions: A101211 (same with rows reversed), A066099, A108244 and A124734.
Each row n >= 1 contains the initial A005811(n) nonzero terms from the beginning of row n of A227186. A070939(n) gives the sum of terms on row n, while A167489(n) gives the product of its terms. A136480 gives the first column. A101211 lists the terms of each row in reverse order.

Examples

			Table begins as:
  Row  n in    Terms on
   n   binary  that row
   1      1    1;
   2     10    1,1;
   3     11    2;
   4    100    2,1;
   5    101    1,1,1;
   6    110    1,2;
   7    111    3;
   8   1000    3,1;
   9   1001    1,2,1;
  10   1010    1,1,1,1;
  11   1011    2,1,1;
  12   1100    2,2;
  13   1101    1,1,2;
  14   1110    1,3;
  15   1111    4;
  16  10000    4,1;
etc. with the terms of row n appearing in reverse order compared how the runs of the same length appear in the binary expansion of n (Cf. A101211).
From _Omar E. Pol_, Sep 08 2013: (Start)
Illustration of initial terms:
  ---------------------------------------
  k   m     Diagram        Composition
  ---------------------------------------
  .          _
  1   1     |_|_           1;
  2   1     |_| |          1, 1,
  2   2     |_ _|_         2;
  3   1     |_  | |        2, 1,
  3   2     |_|_| |        1, 1, 1,
  3   3     |_|   |        1, 2,
  3   4     |_ _ _|_       3;
  4   1     |_    | |      3, 1,
  4   2     |_|_  | |      1, 2, 1,
  4   3     |_| | | |      1, 1, 1, 1,
  4   4     |_ _|_| |      2, 1, 1,
  4   5     |_  |   |      2, 2,
  4   6     |_|_|   |      1, 1, 2,
  4   7     |_|     |      1, 3,
  4   8     |_ _ _ _|_     4;
  5   1     |_      | |    4, 1,
  5   2     |_|_    | |    1, 3, 1,
  5   3     |_| |   | |    1, 1, 2, 1,
  5   4     |_ _|_  | |    2, 2, 1,
  5   5     |_  | | | |    2, 1, 1, 1,
  5   6     |_|_| | | |    1, 1, 1, 1, 1,
  5   7     |_|   | | |    1, 2, 1, 1,
  5   8     |_ _ _|_| |    3, 1, 1,
  5   9     |_    |   |    3, 2,
  5  10     |_|_  |   |    1, 2, 2,
  5  11     |_| | |   |    1, 1, 1, 2,
  5  12     |_ _|_|   |    2, 1, 2,
  5  13     |_  |     |    2, 3,
  5  14     |_|_|     |    1, 1, 3,
  5  15     |_|       |    1, 4,
  5  16     |_ _ _ _ _|    5;
.
Also irregular triangle read by rows in which row k lists the compositions of k, k >= 1.
Triangle begins:
 [1];
 [1,1], [2];
 [2,1], [1,1,1], [1,2],[3];
 [3,1], [1,2,1], [1,1,1,1], [2,1,1], [2,2], [1,1,2], [1,3], [4];
 [4,1], [1,3,1], [1,1,2,1], [2,2,1], [2,1,1,1], [1,1,1,1,1], [1,2,1,1], [3,1,1], [3,2], [1,2,2], [1,1,1,2], [2,1,2], [2,3], [1,1,3], [1,4], [5];
Row k has length A001792(k-1).
Row sums give A001787(k), k >= 1.
(End)
		

Crossrefs

Cf. A227738 and also A227739 for similar table for unordered partitions.
Cf. A101211 (rows in reversed order).

Programs

  • Haskell
    import Data.List (group)
    a227736 n k = a227736_tabf !! (n-1) !! (k-1)
    a227736_row n = a227736_tabf !! (n-1)
    a227736_tabf = map (map length . group) $ tail a030308_tabf
    -- Reinhard Zumkeller, Aug 11 2014
    
  • Mathematica
    Array[Length /@ Reverse@ Split@ IntegerDigits[#, 2] &, 34] // Flatten (* Michael De Vlieger, Dec 11 2020 *)
  • PARI
    apply( {A227736_row(n, r=[1], b=n%2)=while(n\=2, n%2==b && r[#r]++ || [b=1-b, r=concat(r,1)]); r}, [1..22]) \\ M. F. Hasler, Mar 11 2025
    
  • Python
    def A227736_row(n): return[len(list(g))for _,g in groupby(bin(n)[:1:-1])]
    from itertools import groupby # M. F. Hasler, Mar 11 2025
  • Scheme
    (define (A227736 n) (A227186bi (A227737 n) (A227740 n))) ;; The Scheme-function for A227186bi has been given in A227186.
    

Formula

a(n) = A227186(A227737(n), A227740(n)).
a(n) = A101211(A227741(n)).

A227184 a(n) = product of parts of the unordered partition encoded with the runlengths of binary expansion of n.

Original entry on oeis.org

1, 1, 1, 2, 4, 1, 2, 3, 9, 4, 1, 8, 6, 2, 3, 4, 16, 9, 4, 18, 16, 1, 8, 27, 12, 6, 2, 12, 8, 3, 4, 5, 25, 16, 9, 32, 36, 4, 18, 48, 81, 16, 1, 32, 54, 8, 27, 64, 20, 12, 6, 24, 24, 2, 12, 36, 15, 8, 3, 16, 10, 4, 5, 6, 36, 25, 16, 50, 64, 9, 32, 75, 144, 36, 4, 72
Offset: 0

Views

Author

Antti Karttunen, Jul 04 2013

Keywords

Comments

a(0) = 1, as 0 is here considered to encode an empty partition {}, and the empty product is one.
Like A129594, this sequence is based on the fact that compositions (i.e., ordered partitions) can be mapped 1-to-1 to partitions by taking the partial sums of the list where one is subtracted from each composant except the first (originally explained by Marc LeBrun in his Jan 11 2006 post on SeqFan mailing list, with an additional twist involving factorization and prime exponents, cf. A129595). The example below show how this works.
Compare the scatterplot of this sequence to those of A002487, A243353, A243499 and A253552.

Examples

			8 has binary expansion "1000", whose runs have lengths [3,1] when arranged from the least significant to the most significant end. Taking partial sums of 3 and 0, we get 3 and 3, whose product is 9, thus a(8) = 9.
For 44, in binary "101100", the run lengths are [2,2,1,1] (from the least significant end), and subtracting one from all terms except the first one, we get [2,1,0,0], whose partial sums are [2,3,3,3], and 2*3*3*3 = 54, thus a(44)=54.
		

Crossrefs

For n>=1, a(n) gives the product of nonzero terms on row n of table A227189/A227739.
Cf. A227183 (gives the corresponding sums).
See also A167489 for a similar sequence, which gives the product of parts of the compositions (ordered partitions).
Cf. A243499, A003963, A243504 (other such product sequences) and A003188, A243353, A075157 (associated permutations mapping between these schemes).
Cf. also A002487, A243353, A253552.

Programs

  • Mathematica
    Table[Function[b, Times @@ Accumulate@ Prepend[If[Length@ b > 1, Rest[b] - 1, {}], First@ b]]@ Map[Length, Split@ Reverse@ IntegerDigits[n, 2]], {n, 0, 75}] // Flatten (* Michael De Vlieger, May 09 2017 *)
  • Python
    def A227184(n):
      '''Product of parts of the unique unordered partition encoded in the run lengths of the binary expansion of n.'''
      p = 1
      b = n%2
      i = 1
      while (n != 0):
        n >>= 1
        if ((n%2) == b): i += 1
        else:
          b = n%2
          p *= i
      return(p)
  • Scheme
    (define (A227184 n) (if (zero? n) 1 (apply * (binexp_to_ascpart n))))
    (define (binexp_to_ascpart n) (let ((runlist (reverse! (binexp->runcount1list n)))) (PARTSUMS (cons (car runlist) (map -1+ (cdr runlist))))))
    (define (binexp->runcount1list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2)) (loop (floor->exact (/ n 2)) (cons count rc) 1 (modulo n 2)))))))
    (define (PARTSUMS a) (cdr (reverse! (fold-left (lambda (psums n) (cons (+ n (car psums)) psums)) (list 0) a))))
    

Formula

Can be also obtained by mapping with an appropriate permutation from the products of parts of each partition computed for other enumerations similar to A227739:
a(n) = A243499(A003188(n)).
a(n) = A003963(A243353(n)).
a(n) = A243504(1+A075157(n)).

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

A227190 a(n) = n minus (product of run lengths in binary representation of n).

Original entry on oeis.org

0, 1, 1, 2, 4, 4, 4, 5, 7, 9, 9, 8, 11, 11, 11, 12, 14, 16, 15, 18, 20, 20, 20, 18, 21, 24, 23, 22, 26, 26, 26, 27, 29, 31, 29, 32, 35, 34, 33, 37, 39, 41, 41, 40, 43, 43, 43, 40, 43, 46, 43, 48, 51, 50, 49, 47, 51, 55, 53, 52, 57, 57, 57, 58, 60, 62, 59, 62
Offset: 1

Views

Author

Antti Karttunen, Jul 04 2013

Keywords

Examples

			For 8, "1000" in binary, the run lengths are 1 and 3, 1*3=3, and 8-3 = 5, thus a(8)=5. For 24, "11000" in binary, the run lengths are 2 and 3, 2*3=6, and 24-6 = 18, thus a(24)=18.
		

Crossrefs

Programs

  • Haskell
    a227190 n = n - a167489 n  -- Reinhard Zumkeller, Jul 05 2013
  • Mathematica
    Table[n-Times@@(Length/@Split[IntegerDigits[n,2]]),{n,70}] (* Harvey P. Dale, Aug 02 2013 *)
  • Scheme
    (define (A227190 n) (- n (A167489 n))) ;; The Scheme-program for A167489 is found under that entry.
    

Formula

a(n) = n - A167489(n).

A227186 Array A(n,k) read by antidiagonals: the length of the (k+1)-th run (k>=0) of binary digits of n, first run starting from the least significant bit of n.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 06 2013

Keywords

Comments

A(n,k) is set to zero if there are less than k+1 runs.
The irregular table A101211 gives the nonzero terms of each row in reverse order. The terms on row n sum to A029837(n+1). The product of nonzero terms on row n>0 is A167489(n). Number of nonzero terms on each row: A005811.

Examples

			The top-left corner of the array:
0, 0, 0, 0, 0, ... (0, in binary 0, has no runs (by convention), thus at first we have all-0 sequence)
1, 0, 0, 0, 0, ... (1, in binary 1, has one run of length 1)
1, 1, 0, 0, 0, ... (2, in binary 10, has two runs of length 1 both)
2, 0, 0, 0, 0, ... (3, in binary 11, has one run of length 2)
2, 1, 0, 0, 0, ... (4, in binary 100, the rightmost run of length 2 given first, then the second run of length 1)
1, 1, 1, 0, 0, ... (5, in binary 101, has three runs of one bit each)
1, 2, 0, 0, 0, ...
3, 0, 0, 0, 0, ...
3, 1, 0, 0, 0, ...
1, 2, 1, 0, 0, ...
1, 1, 1, 1, 0, ...
2, 1, 1, 0, 0, ...
2, 2, 0, 0, 0, ...
1, 1, 2, 0, 0, ...
1, 3, 0, 0, 0, ...
4, 0, 0, 0, 0, ...
		

Crossrefs

Used to compute A227183. Cf. also A163575, A227188, A227189.

Programs

  • Maple
    A227186 := proc(n,k)
        local bdgs,ru,i,b,a;
        bdgs := convert(n,base,2) ;
        if nops(bdgs) = 0 then
            return 0 ;
        end if;
        ru := 0 ;
        i := 1 ;
        b := op(i,bdgs) ;
        a := 1 ;
        for i from 2 to nops(bdgs) do
            if op(i,bdgs) <> op(i-1,bdgs) then
                if ru = k then
                    return a;
                end if;
                a := 1 ;
                ru := ru+1 ;
            else
                a := a+1 ;
            end if;
        end do:
        if ru =k then
            a ;
        else
            0 ;
        end if;
    end proc: # R. J. Mathar, Jul 23 2013
  • PARI
    A227186(n,k)=while(k>=0,for(c=1,n,bittest(n,0)==bittest(n\=2,0)&next;k&break;return(c));n||return;k--) \\ To let A(0,0)=1 add "!n||!" in front of while(...). TO DO: add default value k=-1 and implement "flattened" sequence, such that A227186(n) yields a(n). M. Hasler, Jul 21 2013
  • Scheme
    (define (A227186 n) (A227186bi (A002262 n) (A025581 n)))
    (define (A227186bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (A227186bi (A163575 n) (- k 1)))))
    

Formula

A(n,0) = A136480(n), n>0.

A227350 Product of lengths of runs of 0-bits in binary representation of n, or 1 if no nonleading zeros present.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 08 2013

Keywords

Examples

			a(0) = 1, regardless whether one considers the binary representation of zero to have one zero or no digits at all, because also the empty product is 1. Similarly for any numbers of form (2^k)-1, where no nonleading 0-bits occur, the result of an empty product is always 1.
a(8) = 3, as 8 is "1000" in binary, and there is one run of three 0-bits present.
a(68) = 6, 68 is "1000100" in binary, there are one run of three 0-bits and one run of two 0-bits, thus 2*3 = 6.
		

Crossrefs

Cf. A023416 (sum of lengths of runs of 0-bits), A167489, A227349, A227355, A227193.

Programs

  • Maple
    a:= proc(n) local i, m, r; m, r:= n, 1;
          while m>0 do
            for i from 0 while irem(m, 2, 'h')=0 do m:=h od;
            while irem(m, 2, 'h')=1 do m:=h od;
            r:= r*max(i, 1)
          od; r
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Jul 11 2013
  • Mathematica
    a[n_] := Times @@ Length /@ Select[Split @ IntegerDigits[n, 2], #[[1]] == 0 &]; Array[a, 100, 0] (* Jean-François Alcover, Mar 03 2016 *)
  • Scheme
    (define (A227350 n) (apply * (bisect (reverse (binexp->runcount1list n)) (modulo n 2))))
    (define (bisect lista parity) (let loop ((lista lista) (i 0) (z (list))) (cond ((null? lista) (reverse! z)) ((eq? i parity) (loop (cdr lista) (modulo (1+ i) 2) (cons (car lista) z))) (else (loop (cdr lista) (modulo (1+ i) 2) z)))))
    (define (binexp->runcount1list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2)) (loop (floor->exact (/ n 2)) (cons count rc) 1 (modulo n 2)))))))

Formula

A167489(n) = a(n) * A227349(n).
A227193(n) = A227349(n) - a(n).
A227355(n) = a(A003714(n)).
A003714 gives the only terms k for which a(k) = A167489(k).

A284559 a(n) = LCM of run lengths in binary representation of n.

Original entry on oeis.org

1, 1, 1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 2, 2, 3, 4, 4, 3, 2, 2, 2, 1, 2, 3, 6, 2, 2, 2, 6, 3, 4, 5, 5, 4, 3, 6, 2, 2, 2, 6, 3, 2, 1, 2, 2, 2, 3, 4, 4, 6, 2, 2, 2, 2, 2, 6, 3, 6, 3, 6, 4, 4, 5, 6, 6, 5, 4, 4, 6, 3, 6, 3, 6, 2, 2, 2, 2, 2, 6, 4, 4, 3, 2, 2, 2, 1, 2, 3, 6, 2, 2, 2, 6, 3, 4, 5, 10, 4, 6, 6, 2, 2, 2, 6, 6, 2, 2, 2, 2, 2, 6, 4, 12, 3, 6, 6, 6, 3, 6, 3
Offset: 0

Views

Author

Antti Karttunen, Apr 14 2017

Keywords

Examples

			For n=12, A007088(12) = "1100" in binary, the run lengths are [2,2], thus a(12) = lcm(2,2) = 2.
		

Crossrefs

Cf. A000975 (positions of ones).

Programs

  • Python
    from math import lcm
    from itertools import groupby
    def a(n): return lcm(*(len(list(g)) for k, g in groupby(bin(n)[2:])))
    print([a(n) for n in range(87)]) # Michael S. Branicky, Oct 15 2022
  • Scheme
    (define (A284559 n) (apply lcm (binexp->runcount1list n)))
    ;; Or:
    (define (A284559 n) (reduce lcm 1 (binexp->runcount1list n))) ;; For binexp->runcount1list, see the Program section of A227349.
    

Formula

a(n) = A167489(n) / A284558(n).
Showing 1-10 of 17 results. Next