cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A093048 a(n) = n minus exponent of 2 in n, with a(0) = 0.

Original entry on oeis.org

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

Views

Author

Ralf Stephan, Mar 16 2004

Keywords

Examples

			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
		

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.

Programs

  • 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 *)
  • 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

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