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.

A340161 a(n) is the smallest number k for which the set {k + 1, k + 2, ..., k + k} contains exactly n elements with exactly three 1-bits (A014311).

Original entry on oeis.org

1, 4, 6, 7, 10, 11, 13, 18, 19, 21, 25, 34, 35, 37, 41, 49, 66, 67, 69, 73, 81, 97, 130, 131, 133, 137, 145, 161, 193, 258, 259, 261, 265, 273, 289, 321, 385, 514, 515, 517, 521, 529, 545, 577, 641, 769, 1026, 1027, 1029, 1033, 1041, 1057, 1089, 1153, 1281, 1537
Offset: 0

Views

Author

Marius A. Burtea, Dec 30 2020

Keywords

Comments

When n = m*(m-1)/2 + 1, m >= 2 (A000124 \ {1}), then a(n) = k = 2^m+2, m >= 2 (A052548 \ {3, 4}), and only for these values of k, there exists only one set, {k+1, k+2, ..., 2k}, that contains exactly n elements whose binary representation has exactly three 1's (see A340068). - Bernard Schott, Jan 03 2021
From David A. Corneth, Jan 03 2021: (Start)
a(n) = A018900(n) + 1 for n >= 1.
Proof: Let T(k) be the number of values in {k+1, k+2, ..., k+k} that have exactly 3 ones in their binary expansion. Let h(k) be 1 if k has exactly 3 ones in its binary expansion and 0 otherwise and let w(k) be the binary weight of k (cf. A000120). Then T(k + 1) = T(k) + h(2*k + 1) + h(2*k + 2) - h(k + 1) = T(k) + h(2*k + 1) + h(2*(k + 1)) - h(k + 1) but as h(2^m * k) = h(k) two terms cancel and we have T(k + 1) = T(k) + h(2*k + 1). If w(2*k + 1) = w(k) + 1 = 3 then w(k) = 2 which holds for k in A018900. (End)

Examples

			For k in {1, 2, 3}, the sets are {1, 2}, {3, 4} and {4, 5, 6}, which do not contain numbers in A014311, so a(0) = 1.
For k = 4, the set is {5, 6, 7, 8} with 7 = A014311(1), so a(1) = 4.
For k = 6, the set {7, 8, 9, 10, 11, 12} contains the elements 7 = A014311(1) and 11 = A014311(2), so a(2) = 6.
		

Crossrefs

Essentially a duplicate of A018900 - N. J. A. Sloane, Jan 23 2021.
Cf. also A000124, A052548 \ {3} (is a subsequence).

Programs

  • Magma
    fb:=func; a:=[]; for n in [0..64] do k:=1; while #[s:s in [k+1..2*k]|fb(s)] ne n do k:=k+1; end while; Append(~a,k); end for; a;
    
  • PARI
    first(n) = {my(res = vector(n), t = 1); res[1] = 1; for(i = 2, oo, if(hammingweight(2*i-1) == 3, t++; if(t > n, return(res)); res[t] = i))} \\ David A. Corneth, Jan 03 2021
    
  • Python
    from math import isqrt, comb
    def A340161(n): return 1+(1<<(m:=isqrt(n<<3)+1>>1))+(1<<(n-1-comb(m,2))) if n else 1 # Chai Wah Wu, Mar 10 2025

Formula

From Bernard Schott, Jan 03 2021: (Start)
a(m*(m-1)/2 + 1) = 2^m + 2 for m >= 2.
a(m*(m-1)/2 + 2) = 2^m + 3 for m >= 2.
a(n) = A018900(n) + 1 for n >= 1 (see A340068). (End)