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

A167489 Product 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, 4, 2, 3, 4, 4, 3, 2, 4, 2, 1, 2, 3, 6, 4, 2, 4, 6, 3, 4, 5, 5, 4, 3, 6, 4, 2, 4, 6, 3, 2, 1, 2, 4, 2, 3, 4, 8, 6, 4, 8, 4, 2, 4, 6, 9, 6, 3, 6, 8, 4, 5, 6, 6, 5, 4, 8, 6, 3, 6, 9, 6, 4, 2, 4, 8, 4, 6, 8, 4, 3, 2, 4, 2, 1, 2, 3, 6, 4, 2, 4, 6, 3, 4, 5, 10, 8, 6, 12, 8, 4, 8
Offset: 0

Views

Author

Andrew Weimholt, Nov 05 2009

Keywords

Examples

			a(56) = 9, because 56 in binary is written 111000 giving the run lengths 3,3 and 3x3 = 9.
a(99) = 12, because 99 in binary is written 1100011 giving the run lengths 2,3,2, and 2x3x2 = 12.
		

Crossrefs

Row products of A101211 and A227736 (for n > 0).
Cf. A167490 (smallest number with binary run length product = n).
Cf. A167491 (members of A167490 sorted in ascending order).
Differs from similar A284579 for the first time at n=56, where a(56) = 9, while A284579(56) = 5.

Programs

  • Haskell
    import Data.List (group)
    a167489 = product . map length . group . a030308_row
    -- Reinhard Zumkeller, Jul 05 2013
    
  • Mathematica
    Table[ Times @@ (Length /@ Split[IntegerDigits[n, 2]]), {n, 0, 100}](* Olivier Gérard, Jul 05 2013 *)
  • PARI
    a(n) = {my(p=1, b=n%2, i=0); while(n!=0, n=n>>1; i=i+1; if((n%2)!=b, p=p*i; i=0; b=n%2)); p} \\ Indranil Ghosh, Apr 17 2017, after the Python Program by Antti Karttunen
  • Python
    def A167489(n):
      '''Product of run lengths in binary representation of n.'''
      p = 1
      b = n%2
      i = 0
      while (n != 0):
        n >>= 1
        i += 1
        if ((n%2) != b):
          p *= i
          i = 0
          b = n%2
      return(p)
    # Antti Karttunen, Jul 24 2013 (Cf. Python program for A227184).
    
  • Scheme
    (define (A167489 n) (apply * (binexp->runcount1list n)))
    (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)))))))
    ;; Antti Karttunen, Jul 05 2013
    

Formula

a(n) = A227349(n) * A227350(n) = A227355(A227352(2n+1)). - Antti Karttunen, Jul 25 2013
a(n) = A284558(n) * A284559(n) = A284582(n) * A284583(n). - Antti Karttunen, Apr 16 2017

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).

A227352 Permutation of nonnegative integers: map each number by lengths of runs in its binary representation to the number in whose once left-shifted Zeckendorf representation occurs the same run lengths (in the same order) as the lengths of consecutive blocks of zeros.

Original entry on oeis.org

0, 1, 4, 2, 7, 12, 6, 3, 11, 19, 33, 20, 10, 17, 9, 5, 18, 30, 51, 31, 54, 88, 53, 32, 16, 27, 46, 28, 15, 25, 14, 8, 29, 48, 80, 49, 83, 135, 82, 50, 87, 142, 232, 143, 86, 140, 85, 52, 26, 43, 72, 44, 75, 122, 74, 45, 24, 40, 67, 41, 23, 38, 22, 13, 47, 77
Offset: 0

Views

Author

Antti Karttunen, Jul 08 2013

Keywords

Comments

See the comments at the inverse permutation A227351 where the idea behind this mapping is explained.

Crossrefs

Inverse permutation: A227351. Cf. A048680, A003188.

Programs

Formula

a(n) = A048680(A003188(n)). [The defining formula]
Moreover, this permutation effects the following correspondences:
For n>=1 A000523(n) = A102364(a(n)).
For all n, A167489(n) = A227355(a(2n+1)).
Showing 1-3 of 3 results.