OFFSET
0,4
FORMULA
Recurrence: a(2n) = a(n) + n - 1, a(2n+1) = 2n.
G.f.: sum(k>=0, t^3(t+2)/(1-t^2)^2, t=x^2^k).
EXAMPLE
G.f. = 2*x^3 + x^4 + 4*x^5 + 4*x^6 + 6*x^7 + 4*x^8 + 8*x^9 + 8*x^10 + ... - Michael Somos, Jan 25 2020
MATHEMATICA
a[ n_] := If[ n == 0, 0, n - 1 - 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-1))
(PARI) {a(n) = if( n, n - 1 - valuation(n, 2))}; /* Michael Somos, Jan 25 2020 */
(Python)
def A093049(n): return n-1-(~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