login
A093048
a(n) = n minus exponent of 2 in n, with a(0) = 0.
4
0, 1, 1, 3, 2, 5, 5, 7, 5, 9, 9, 11, 10, 13, 13, 15, 12, 17, 17, 19, 18, 21, 21, 23, 21, 25, 25, 27, 26, 29, 29, 31, 27, 33, 33, 35, 34, 37, 37, 39, 37, 41, 41, 43, 42, 45, 45, 47, 44, 49, 49, 51, 50, 53, 53, 55, 53, 57, 57, 59, 58, 61, 61, 63, 58, 65, 65, 67, 66, 69
OFFSET
0,4
LINKS
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
A093048 := proc(n)
n-A007814(n) ;
end proc: # R. J. Mathar, Jul 24 2014
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
a(n) = n - A007814(n) = A093049(n) + 1, n > 0.
a(n) is the exponent of 2 in A002689(n-1), A014070(n), A060690(n), A075101(n).
See also A084623.
Sequence in context: A019828 A289627 A115207 * A141732 A325695 A186545
KEYWORD
nonn
AUTHOR
Ralf Stephan, Mar 16 2004
STATUS
approved