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