Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
login
A147760
a(n) is the smallest positive integer m with exactly n ones in its binary representation and with n represented in binary as a substring of the binary representation of m.
3
1, 5, 7, 39, 47, 111, 127, 1151, 1279, 2815, 3071, 13311, 14335, 30719, 32767, 557055, 589823, 1245183, 1310719, 5505023, 5767167, 12058623, 12582911, 104857599, 109051903, 226492415, 234881023, 973078527, 1006632959, 2080374783, 2147483647, 70866960383
OFFSET
1,2
COMMENTS
a(3320) has 1001 digits. - Michael S. Branicky, Feb 18 2023
LINKS
FORMULA
a(n) = n*2^m + 2^m - 1 where m = n - A000120(n). - Michael S. Branicky, Feb 18 2023
EXAMPLE
6 represented in binary is 110. 111 (decimal) represented in binary is 1101111, which contains exactly six 1's and 110 as a substring ({110}1111). Since 111 is the smallest positive integer that satisfies the conditions, then a(6) = 111.
PROG
(Python)
def a(n): b = bin(n)[2:]; m = n - b.count("1"); return (n<<m) + (1<<m) - 1
print([a(n) for n in range(1, 33)]) # 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(31) and beyond from Michael S. Branicky, Feb 18 2023
STATUS
approved