OFFSET
1,1
COMMENTS
a(1662) has 1001 digits. - Michael S. Branicky, Feb 18 2023
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..1661
FORMULA
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
EXAMPLE
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.
PROG
(Python)
def a(n):
b = bin(n)[2:]
t = b.rstrip("0")
if t == "1": return int("1" + "0"*n + "1"*(n-1), 2)
return int("1" + "0"*(n-b.count("0")) + b + "1"*(n-1-b.count("1")), 2)
print([a(n) for n in range(1, 26)]) # Michael S. Branicky, Feb 18 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Nov 11 2008
EXTENSIONS
Extended by Ray Chandler, Nov 15 2008
a(24) and beyond from Michael S. Branicky, Feb 18 2023
STATUS
approved