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.

A089265 a(1) = 0; thereafter a(2*n) = a(n) + 1, a(2*n+1) = 2*n.

Original entry on oeis.org

0, 1, 2, 2, 4, 3, 6, 3, 8, 5, 10, 4, 12, 7, 14, 4, 16, 9, 18, 6, 20, 11, 22, 5, 24, 13, 26, 8, 28, 15, 30, 5, 32, 17, 34, 10, 36, 19, 38, 7, 40, 21, 42, 12, 44, 23, 46, 6, 48, 25, 50, 14, 52, 27, 54, 9, 56, 29, 58, 16, 60, 31, 62, 6, 64, 33, 66, 18, 68, 35, 70, 11, 72
Offset: 1

Views

Author

Ralf Stephan, Oct 30 2003

Keywords

Comments

In the binary representation of n, swallow all zeros from the right, then add the number of swallowed zeros, and subtract 1. - Ralf Stephan, Aug 22 2013

Crossrefs

First differences of A005766.

Programs

  • Maple
    nmax:=73: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := p  + 2*(n-1) od: od: seq(a(n), n=1..nmax); # Johannes W. Meijer, Jan 23 2013
  • Mathematica
    a[n_] := With[{v = IntegerExponent[n, 2]}, v + n/2^v - 1];
    Array[a, 100] (* Jean-François Alcover, Feb 28 2019 *)
  • PARI
    a(n) = valuation(n,2) + n/2^valuation(n,2) - 1

Formula

a(1) = 0; thereafter a(2*n) = a(n) + 1, a(2*n+1) = 2*n.
a(n) = A007814(n) + 2*A025480(n-1) = A007814(n) + A000265(n) - 1.
G.f.: sum(k>=0, (t^2+2t^3-t^4)/(1-t^2)^2, t=(x^2)^k).
a((2*n-1)*2^p) = p + 2*(n-1), p >= 0. - Johannes W. Meijer, Jan 23 2013