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.

A069010 Number of runs of 1's in the binary representation of n.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Apr 02 2002

Keywords

Comments

a(n) is also the number of distinct parts in the integer partition having viabin number n. The viabin number of an integer partition is defined in the following way. Consider the southeast border of the Ferrers board of the integer partition and consider the binary number obtained by replacing each east step with 1 and each north step, except the last one, with 0. The corresponding decimal form is, by definition, the viabin number of the given integer partition. "Viabin" is coined from "via binary". For example, consider the integer partition [2,2,2,1]. The southeast border of its Ferrers board yields 10100, leading to the viabin number 20. - Emeric Deutsch, Jul 24 2017
Positions of first occurrences of k are A002450(k). - John Keith, Aug 30 2021

Examples

			a(11) = 2 since 11 is 1011 in binary with two runs of 1's.
a(12) = 1 since 12 is 1100 in binary with one run of 1's.
		

Crossrefs

Cf. A268411 (parity of the terms), A268412 (positions of even terms), A268415 (of odd terms).
Cf. A002450 (positions of record highs).
Cf. also A227349, A246588.

Programs

  • Maple
    f:= proc(n) option remember; if n::even then procname(n/2)
    elif n mod 4 = 1 then 1 + procname((n-1)/2) else  procname((n-1)/2) fi end proc:
    f(0):= 0:
    map(f, [$0..1000]); # Robert Israel, Sep 06 2015
  • Mathematica
    Count[Split@ IntegerDigits[#, 2], n_ /; First@ n == 1] & /@ Range[0, 120] (* Michael De Vlieger, Sep 05 2015 *)
  • PARI
    a(n) = (1 + (hammingweight(bitxor(n, n>>1)))) >> 1;  \\ Gheorghe Coserea, Sep 05 2015
    
  • Python
    def A069010(n):
        return sum(1 for d in bin(n)[2:].split('0') if len(d)) # Chai Wah Wu, Nov 04 2016
  • Scheme
    (define (A069010 n) (/ (+ (A005811 n) (A000035 n)) 2)) ;; Antti Karttunen, Feb 05 2016
    

Formula

a(n) = ceiling(A005811(n)/2) = A005811(n) - A033264(n). If 2^k <= n < 3*2^(k-1) then a(n) = a(n-2^k)+1; if 3*2^(k-1) <= n < 2^(k+1) then a(n) = a(n-2^k).
a(2n) = a(n), a(2n+1) = a(n) + [n is even]. - Ralf Stephan, Aug 20 2003
G.f.: (1/(1-x)) * Sum_{k>=0} (t/(1+t))/(1+t^2), where t=x^2^k. - Ralf Stephan, Sep 07 2003
a(n) = A000120(n) - A014081(n) = A037800(n) + 1, n>0. - Ralf Stephan, Sep 10 2003