STATUS
reviewed
approved
reviewed
approved
proposed
reviewed
editing
proposed
s = bin(n)[2:]
return (n>>l-k)+(int(sbin(n)[k-+1:1:-1], or '0', 2)<(n&(1<<k)-1))+(1<<k-1+(l&1^1)) # Chai Wah Wu, Jul 24 2024
proposed
editing
editing
proposed
return (n>>l-k)+(int(s[k-1::-1], 2)<(n&(1<<k)-1))+(1<<k-1+(l&1^1)) # Chai Wah Wu, Jul 24 2024
(Python)
def A206916(n):
s = bin(n)[2:]
l = n.bit_length()
k = l+1>>1
return (n>>l-k)+(int(s[k-1::-1], 2)<(n&(1<<k)-1))+(1<<k-1+(l&1^1)) # Chai Wah Wu, Jul 24 2024
approved
editing
editing
approved
editing
approved