%I #10 Feb 18 2023 14:25:36
%S 2,9,35,135,535,2103,8255,32895,131711,525695,2098687,8395263,
%T 33561599,134233087,536887295,2147516415,8590229503,34360360959,
%U 137439608831,549758566399,2199026139135,8796099051519,35184378380287,140737540784127,562950007947263
%N a(n) is the smallest positive integer m with exactly n zeros and exactly n ones in its binary representation and with n represented in binary as a substring of the binary representation of m.
%C a(1662) has 1001 digits. - _Michael S. Branicky_, Feb 18 2023
%H Michael S. Branicky, <a href="/A147762/b147762.txt">Table of n, a(n) for n = 1..1661</a>
%F a(n) = 2^(2n-1) + 2^(n-1) - 1 if n is a power of 2; else a(n) = 2^(2n-1) + n*2^m + 2^m - 1 where m = n - 1 - A000120(n). - _Michael S. Branicky_, Feb 18 2023
%e 6 represented in binary is 110. 2103 represented in binary is 100000110111, which contains exactly six 0's and exactly six 1's and contains 110 as a substring (100000{110}111). Since 2103 is the smallest positive integer that satisfies the conditions, then a(6) = 2103.
%o (Python)
%o def a(n):
%o b = bin(n)[2:]
%o t = b.rstrip("0")
%o if t == "1": return int("1" + "0"*n + "1"*(n-1), 2)
%o return int("1" + "0"*(n-b.count("0")) + b + "1"*(n-1-b.count("1")), 2)
%o print([a(n) for n in range(1, 26)]) # _Michael S. Branicky_, Feb 18 2023
%Y Cf. A000120, A023416, A147760, A147761.
%K base,nonn
%O 1,1
%A _Leroy Quet_, Nov 11 2008
%E Extended by _Ray Chandler_, Nov 15 2008
%E a(24) and beyond from _Michael S. Branicky_, Feb 18 2023