login
Odd numbers with two zeros in their binary expansion.
4

%I #59 Oct 21 2022 15:27:00

%S 9,19,21,25,39,43,45,51,53,57,79,87,91,93,103,107,109,115,117,121,159,

%T 175,183,187,189,207,215,219,221,231,235,237,243,245,249,319,351,367,

%U 375,379,381,415,431,439,443,445,463,471,475,477,487,491,493,499,501

%N Odd numbers with two zeros in their binary expansion.

%C A048490 \ {1} is a subsequence, since for m >= 1, A048490(m) = 8*2^m - 7 has 11..11001 with m starting 1 for binary expansion.

%C A153894 \ {4} is a subsequence, since for m >= 1, A153894(m) = 5*2^m - 1 has 10011..11 with m trailing 1 for binary expansion.

%C A220236 is a subsequence, since for m >= 1, A220236(m) = 2^(2*m + 2) - 2^(m + 1) - 2^m - 1 has 11..110011..11 with m starting 1 and m trailing 1 for binary expansion.

%C For k > 2, there are (k-1)*(k-2)/2 terms between 2^k and 2^(k+1), or equivalently (k-1)*(k-2)/2 terms with k+1 bits.

%C Binary expansion of a(n) is A357774(n).

%C {4*a(n), n>0} form a subsequence of A353654 (numbers with two trailing 0 bits and two other 0 bits).

%F A023416(a(n)) = 2.

%F a((n-1)*(n-2)*(n-3)/6 - (i-1)*(i-2)/2 - (j-1)) = 2^n - 2^i - 2^j - 1 for 1 <= j < i <= n-2. - _Robert Israel_, Oct 13 2022

%p seq(seq(seq(2^n-1-2^i-2^j,j=i-1..1,-1),i=n-2..1,-1),n=4..10); # _Robert Israel_, Oct 13 2022

%t Select[Range[1, 500, 2], DigitCount[#, 2, 0] == 2 &] (* _Amiram Eldar_, Oct 12 2022 *)

%o (Python)

%o def a(n):

%o m = 0

%o while m*(m+1)*(m+2)//6 <= n: m += 1

%o m -= 1 # m = A056556(n-1)

%o k, r, j = m + 4, n - m*(m+1)*(m+2)//6, 0

%o while r >= 0: r -= (m+1-j); j += 1

%o j += 1

%o return 2**k - 2**(k-j) - 2**(-r) - 1

%o print([a(n) for n in range(60)]) # _Michael S. Branicky_, Oct 12 2022

%o (Python) # faster version for generating initial segment of sequence

%o from itertools import combinations, count, islice

%o def agen():

%o for d in count(4):

%o b, c = 2**d - 1, 2**(d-1)

%o for i, j in combinations(range(1, d-1), 2):

%o yield b - (c >> i) - (c >> j)

%o print(list(islice(agen(), 60))) # _Michael S. Branicky_, Oct 13 2022

%o (PARI) isok(k) = (k%2) && (#binary(k) == hammingweight(k)+2); \\ _Michel Marcus_, Oct 13 2022

%o (PARI) list(lim)=my(v=List()); for(n=4,logint(lim\=1,2)+1, my(N=2^n-1); forstep(a=n-2,2,-1, my(A=N-1<<a); forstep(b=a-1,1,-1, my(t=A-1<<b); if(t>lim, break(2)); listput(v,t)))); Vec(v) \\ _Charles R Greathouse IV_, Oct 21 2022

%Y Cf. A018900, A005408, A023416, A353654, A357774.

%Y Odd numbers with k zeros in their binary expansion: A000225 (k=0), A190620 (k=1).

%Y Subsequences: A048490 \ {1}, A153894 \ {4}, A220236.

%K nonn,base,easy

%O 1,1

%A _Bernard Schott_, Oct 12 2022

%E a(11) and beyond from _Michael S. Branicky_, Oct 12 2022