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

A236840 n minus number of runs in the binary expansion of n: a(n) = n - A005811(n).

Original entry on oeis.org

0, 0, 0, 2, 2, 2, 4, 6, 6, 6, 6, 8, 10, 10, 12, 14, 14, 14, 14, 16, 16, 16, 18, 20, 22, 22, 22, 24, 26, 26, 28, 30, 30, 30, 30, 32, 32, 32, 34, 36, 36, 36, 36, 38, 40, 40, 42, 44, 46, 46, 46, 48, 48, 48, 50, 52, 54, 54, 54, 56, 58, 58, 60, 62, 62, 62, 62, 64, 64, 64
Offset: 0

Views

Author

Antti Karttunen, Apr 18 2014

Keywords

Comments

All terms are even. Used by the "number-of-runs beanstalk" sequence A255056 and many of its associated sequences.

Crossrefs

Cf. A091067 (the positions of records), A106836 (run lengths).
Cf. A255070 (terms divided by 2).

Programs

  • Maple
    A236840 := proc(n) local i, b; if n=0 then 0 else b := convert(n, base, 2); select(i -> (b[i-1]<>b[i]), [$2..nops(b)]); n-1-nops(%) fi end: seq(A236840(i), i=0..69); # Peter Luschny, Apr 19 2014
  • Mathematica
    a[n_] := n - Length@ Split[IntegerDigits[n, 2]]; a[0] = 0; Array[a, 100, 0] (* Amiram Eldar, Jul 16 2023 *)
  • Scheme
    (define (A236840 n)  (- n (A005811 n)))

Formula

a(n) = n - A005811(n) = n - A000120(A003188(n)).
a(n) = 2*A255070(n).

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

A227191 a(n) = n minus (product of nonzero digits in factorial base representation of n).

Original entry on oeis.org

0, 1, 2, 2, 3, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 12, 13, 15, 16, 17, 18, 16, 17, 23, 24, 25, 26, 26, 27, 29, 30, 31, 32, 32, 33, 34, 35, 36, 37, 36, 37, 39, 40, 41, 42, 40, 41, 46, 47, 48, 49, 48, 49, 52, 53, 54, 55, 54, 55, 56, 57, 58, 59, 56, 57, 60, 61, 62
Offset: 1

Views

Author

Antti Karttunen, Jul 04 2013

Keywords

Examples

			22 has factorial expansion A007623(22) = "320", and multiplying the nonzero digits, we get 3*2 = 6, and 22-6 = 16, thus a(22)=16.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{k = n, m = 2, r, p = 1}, While[{k, r} = QuotientRemainder[k, m]; k != 0|| r != 0, If[r > 0, p *= r]; m++]; n - p]; Array[a, 100] (* Amiram Eldar, Feb 14 2024 *)
  • Scheme
    (define (A227191 n) (- n (A227153 n)))

Formula

a(n) = n - A227153(n).

A237449 a(n) = n - A236855(n).

Original entry on oeis.org

0, 0, 1, 1, 1, 4, 4, 5, 5, 5, 7, 7, 7, 7, 13, 13, 14, 14, 14, 17, 17, 18, 18, 18, 20, 20, 20, 20, 25, 25, 26, 26, 26, 28, 28, 28, 28, 31, 31, 31, 31, 31, 41, 41, 42, 42, 42, 45, 45, 46, 46, 46, 48, 48, 48, 48, 54, 54, 55, 55, 55, 58, 58, 59, 59, 59, 61, 61, 61, 61
Offset: 0

Views

Author

Antti Karttunen, Apr 18 2014

Keywords

Crossrefs

Programs

  • Mathematica
    A236855list[m_] := With[{r = 2*Range[2, m]-1}, Reverse[Map[Total[r-#] &, Select[Subsets[Range[2, 2*m-1], {m-1}], Min[r-#] >= 0 &]]]];
    With[{m = 6}, Range[0, CatalanNumber[m]-1] - A236855list[m]] (* Generates C(m) terms *) (* Paolo Xausa, Feb 20 2024 *)
  • Scheme
    (define (A237449 n) (- n (A236855 n)))

Formula

a(n) = n - A236855(n).

A283972 a(n) = n minus (product of lengths of 1-runs in binary representation of n) = n - A227349(n).

Original entry on oeis.org

0, 1, 1, 3, 4, 4, 4, 7, 8, 9, 9, 10, 11, 11, 11, 15, 16, 17, 17, 19, 20, 20, 20, 22, 23, 24, 23, 25, 26, 26, 26, 31, 32, 33, 33, 35, 36, 36, 36, 39, 40, 41, 41, 42, 43, 43, 43, 46, 47, 48, 47, 50, 51, 50, 49, 53, 54, 55, 53, 56, 57, 57, 57, 63, 64, 65, 65, 67, 68, 68, 68, 71, 72, 73, 73, 74, 75, 75, 75, 79, 80, 81, 81, 83, 84, 84, 84, 86, 87, 88, 87, 89
Offset: 1

Views

Author

Antti Karttunen, Apr 14 2017

Keywords

Crossrefs

Cf. A227349.
Cf. A227190, A284560, A284581 for similar sequences.

Programs

Formula

a(n) = n - A227349(n).

A284581 a(n) = n minus (carryless base-2 product of run lengths in binary representation of n) = n - A284579(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, 51, 51, 55, 53, 52, 57, 57, 57, 58, 60, 62, 59, 62, 66, 64, 66, 66, 69, 72, 71, 68, 73, 72, 71, 76, 78, 80, 79, 82, 84, 84, 84, 82, 85, 88, 87, 86
Offset: 1

Views

Author

Antti Karttunen, Apr 14 2017

Keywords

Crossrefs

Cf. A227190, A284560, A283972 for similar sequences.
Differs from A227190 for the first time at n=56, where a(56)=51, while A227190(56)=47.

Programs

Formula

a(n) = n - A284579(n).

A227193 Difference of (product of runlengths of 1-bits) and (product of runlengths of 0-bits) in binary representation of n.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 08 2013

Keywords

Comments

The sequence seems to consist of palindromic subsequences centered around each (2^k)-1 and 2^k (with end points near the terms of A000975), which is easily explained by symmetric pairing of binary expansion of n and its complement.

Crossrefs

Programs

  • Maple
    a:= proc(n) local i, j, m, r, s; m, r, s:= n, 1, 1;
          while m>0 do
            for i from 0 while irem(m, 2, 'h')=0 do m:=h od;
            for j from 0 while irem(m, 2, 'h')=1 do m:=h od;
            r, s:= r*j, s*max(i, 1)
          od; r-s
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Jul 11 2013
  • Mathematica
    a[n_] := With[{s = Split @ IntegerDigits[n, 2]}, Times @@ Length /@ Select[ s, First[#]==1&] - Times @@ Length /@ Select[s , First[#]==0&]]; Table[ a[n], {n, 0, 100}] (* Jean-François Alcover, Feb 28 2016 *)
  • Scheme
    (define (A227193 n) (- (A227349 n) (A227350 n)))

Formula

a(n) = A227349(n) - A227350(n).

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

Original entry on oeis.org

0, 1, 1, 2, 4, 4, 4, 5, 7, 9, 9, 10, 11, 11, 11, 12, 14, 16, 17, 18, 20, 20, 20, 18, 23, 24, 25, 22, 26, 26, 26, 27, 29, 31, 29, 34, 35, 36, 33, 37, 39, 41, 41, 42, 43, 43, 43, 44, 43, 48, 49, 50, 51, 52, 49, 53, 51, 55, 53, 56, 57, 57, 57, 58, 60, 62, 63, 62, 66, 64, 68, 66, 71, 72, 73, 74, 75, 72, 75, 76, 78, 80, 81, 82, 84, 84, 84, 82, 87, 88, 89, 86
Offset: 1

Views

Author

Antti Karttunen, Apr 14 2017

Keywords

Crossrefs

Cf. A284559.
Cf. A227190, A283972, A284581 for similar sequences.

Programs

Formula

a(n) = n - A284559(n).
Showing 1-8 of 8 results.