OFFSET
0,4
LINKS
R. J. Mathar, Table of n, a(n) for n = 0..1000
FORMULA
Recurrence: a(2n) = a(n) + n - 1, a(2n+1) = 2n + 1.
G.f.: Sum_{k>=0} (t*(t^3 + t^2 + 1)/(1 - t^2)^2), with t = x^2^k.
a(n) = Sum_{k=1..n} sign(n mod 2^k). - Wesley Ivan Hurt, May 09 2021
EXAMPLE
G.f. = x + x^2 + 3*x^3 + 2*x^4 + 5*x^5 + 5*x^6 + 7*x^7 + 5*x^8 + 9*x^9 + ... - Michael Somos, Jan 25 2020
MAPLE
MATHEMATICA
a[ n_] := If[ n == 0, n - IntegerExponent[n, 2]]; (* Michael Somos, Jan 25 2020 *)
PROG
(PARI) a(n) = if(n<1, 0, if(n%2==0, a(n/2) + n/2 - 1, n))
(PARI) a(n) = n - valuation(n, 2) \\ Jianing Song, Oct 24 2018
(Python)
def A093048(n): return n-(~n& n-1).bit_length() if n else 0 # Chai Wah Wu, Jul 07 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Ralf Stephan, Mar 16 2004
STATUS
approved