A342126 The binary expansion of a(n) corresponds to that of n where all the 1's have been replaced by 0's except in the first run of 1's.
0, 1, 2, 3, 4, 4, 6, 7, 8, 8, 8, 8, 12, 12, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 24, 24, 28, 28, 30, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 56, 56, 56, 56, 60, 60, 62, 63, 64, 64, 64, 64
Offset: 0
Examples
The first terms, alongside their binary expansion, are: n a(n) bin(n) bin(a(n)) -- ---- ------ --------- 0 0 0 0 1 1 1 1 2 2 10 10 3 3 11 11 4 4 100 100 5 4 101 100 6 6 110 110 7 7 111 111 8 8 1000 1000 9 8 1001 1000 10 8 1010 1000 11 8 1011 1000 12 12 1100 1100 13 12 1101 1100 14 14 1110 1110 15 15 1111 1111
Links
Programs
-
PARI
a(n) = { my (b=binary(n), p=1); for (k=1, #b, b[k] = p*=b[k]); fromdigits(b, 2) }
-
Python
def A342126(n): s = bin(n)[2:] i = s.find('0') return n if i == -1 else (2**i-1)*2**(len(s)-i) # Chai Wah Wu, Apr 29 2021
Comments