OFFSET
1,4
COMMENTS
a(n) <= (n/2)*log_2 n, with equality at powers of 2.
FORMULA
a(n) = Sum_{i=1..n} (-1)^i*A006519(i).
a(n) = A136013(n) - (n mod 2). - Kevin Ryde, Jan 01 2024
MATHEMATICA
a[1]=-1; a[n_]:=If[OddQ[n], a[n-1]-2^IntegerExponent[n, 2], a[n-1]+2^IntegerExponent[n, 2]]; Table[a[n], {n, 63}] (* James C. McMahon, Dec 31 2023 *)
PROG
(PARI) a(n) = fromdigits(Vec(Pol(binary(n))'), 2) - bitand(n, 1); \\ Kevin Ryde, Jan 01 2024
(Python)
def A368595(n): return sum(map(lambda x:(x[0]+1)*(1<<x[0]), filter(lambda x:x[1]=='1', enumerate(bin(n)[-2:1:-1]))))-(n&1) # Chai Wah Wu, Jan 01 2024
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Jeffrey Shallit, Dec 31 2023
STATUS
approved