OFFSET
1,2
COMMENTS
Construction: take the binary expansion of n, and substitute "01" for all trailing 0-bits that follow after its odd part (= A000265(n)). See the examples.
FORMULA
For n >= 0, a(2n+1) = 2n+1.
EXAMPLE
For n=4, "100" in binary, when we substitute 01's for the two trailing 0's, we obtain 21, "10101" in binary, therefore a(4) = 21.
For n=11, "1011" in binary, there are no trailing 0's, and thus no changes, therefore a(11) = 11.
MAPLE
a := proc(n) padic[ordp](n, 2): n*2^% + ((2^%)^2 - 1)/3 end:
seq(a(n), n = 1..64); # Peter Luschny, Apr 27 2024
MATHEMATICA
a[n_]:=n*(2^IntegerExponent[n, 2]) + ((4^IntegerExponent[n, 2]) - 1)/3; Array[a, 75] (* Stefano Spezia, Apr 26 2024 *)
PROG
(PARI) A372289(n) = { my(e=valuation(n, 2)); ((n*(2^e)) + (((4^e)-1)/3)); };
(Python)
def A372289(n): return (n<<(e:=(~n & n-1).bit_length()))+((1<<(e<<1))-1)//3 # Chai Wah Wu, Apr 26 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen and Ali Sada, Apr 26 2024
STATUS
approved