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.

A161511 Number of 1...0 pairs in the binary representation of 2n.

This page as a plain text file.
%I A161511 #50 Jul 08 2025 23:03:43
%S A161511 0,1,2,2,3,3,4,3,4,4,5,4,6,5,6,4,5,5,6,5,7,6,7,5,8,7,8,6,9,7,8,5,6,6,
%T A161511 7,6,8,7,8,6,9,8,9,7,10,8,9,6,10,9,10,8,11,9,10,7,12,10,11,8,12,9,10,
%U A161511 6,7,7,8,7,9,8,9,7,10,9,10,8,11,9,10,7,11,10,11,9,12,10,11,8,13,11,12,9,13
%N A161511 Number of 1...0 pairs in the binary representation of 2n.
%C A161511 Row (partition) sums of A125106.
%C A161511 a(n) is also the weight (= sum of parts) of 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
%H A161511 Antti Karttunen, <a href="/A161511/b161511.txt">Table of n, a(n) for n = 0..8192</a>
%H A161511 Peter J. Taylor, <a href="https://mathoverflow.net/a/497188/231922">Recursion for A161511</a>, answer to question on MathOverflow (2025).
%F A161511 a(0) = 0; a(2n) = a(n) + A000120(n); a(2n+1) = a(n) + 1.
%F A161511 From _Antti Karttunen_, Jun 28 2014: (Start)
%F A161511 Can be also obtained by mapping with an appropriate permutation from the lists of partition sizes computed for other enumerations similar to A125106:
%F A161511 a(n) = A227183(A006068(n)).
%F A161511 a(n) = A056239(A005940(n+1)).
%F A161511 a(n) = A243503(A163511(n)). (End)
%F A161511 a(n) = A029931(n) - binomial(A000120(n),2). - _Gus Wiseman_, Jan 03 2023
%F A161511 a(n) = a(n - A048896(n-1)) + 1 for n>=1 (see _Peter J. Taylor_ link). - _Mikhail Kurkov_, Jul 04 2025
%e A161511 For n = 5, the binary representation of 2n is 1010; the 1...0 pairs are 10xx, 1xx0, and xx10, so a(5) = 3.
%t A161511 a[0] = 0; a[n_] := If[EvenQ[n], a[n/2] + DigitCount[n/2, 2, 1], a[(n-1)/2] + 1]; Array[a, 93, 0] (* _Jean-François Alcover_, Sep 09 2017 *)
%o A161511 (PARI) a(n)=local(t,k);t=0;k=1;while(n>0,if(n%2==0,k++,t+=k);n\=2);t
%o A161511 (Scheme)
%o A161511 ;; Two variants, the recursive one requiring memoizing definec-macro from Antti Karttunen's IntSeq-library.
%o A161511 (define (A161511 n) (let loop ((n n) (i 1) (s 0)) (cond ((zero? n) s) ((even? n) (loop (/ n 2) (+ i 1) s)) (else (loop (/ (- n 1) 2) i (+ s i))))))
%o A161511 (definec (A161511 n) (cond ((zero? n) n) ((even? n) (+ (A000120 n) (A161511 (/ n 2)))) (else (+ 1 (A161511 (/ (- n 1) 2))))))
%o A161511 ;; _Antti Karttunen_, Jun 28 2014
%o A161511 (Python)
%o A161511 def A161511(n):
%o A161511     a, b = 0, 0
%o A161511     for i, j in enumerate(bin(n)[:1:-1], 1):
%o A161511         if int(j):
%o A161511             a += i-b
%o A161511             b += 1
%o A161511     return a # _Chai Wah Wu_, Jul 26 2023
%Y A161511 Cf. A000120, A243499 (gives the corresponding products), A227183, A056239, A243503, A006068, A163511.
%Y A161511 Sum of prime indices of A005940.
%Y A161511 Row sums of A125106.
%Y A161511 A reverse version is A359043, row sums of A242628.
%Y A161511 A029837 adds up standard compositions, row sums of A066099.
%Y A161511 A029931 adds up binary indices, row sums of A048793.
%Y A161511 Cf. A059893, A228351, A230877, A231204, A253565, A358194, A359042, A359359.
%K A161511 nonn,look
%O A161511 0,3
%A A161511 _Franklin T. Adams-Watters_, Jun 11 2009