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.

A136480 Number of trailing equal digits in binary representation of n.

Original entry on oeis.org

1, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 5, 5, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 6, 6, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 2, 2, 1, 1, 5, 5, 1, 1, 2, 2, 1, 1, 3, 3
Offset: 0

Views

Author

Reinhard Zumkeller, Dec 31 2007

Keywords

Comments

a(even) = number of trailing binary zeros;
a(odd) = number of trailing binary ones.
For n>0, power of 2 associated with n^2 + n, e.g. n=4 gives 20, so a(4)=2. - Jon Perry, Sep 12 2014

Crossrefs

Programs

  • Haskell
    a136480 0 = 1
    a136480 n = a007814 $ n + mod n 2  -- Reinhard Zumkeller, Jul 22 2014
    
  • JavaScript
    for (n=1;n<120;n++) {
    m=n*n+n;
    c=0;
    while (m%2==0) {m/=2;c++;}
    document.write(c+", ");
    }  // Jon Perry, Sep 12 2014
    
  • Maple
    A136480 := proc(n)
        if n = 0 then
            1;
        else
            A007814(n*(n+1)) ;
        end if;
    end proc:
    seq( A136480(n),n=0..80) ; # R. J. Mathar, Mar 20 2023
  • Mathematica
    Length[Last[Split[IntegerDigits[#,2]]]]&/@Range[0,140]  (* Harvey P. Dale, Mar 31 2011 *)
  • PARI
    a(n)=if (n, valuation(n+n%2,2), 1) \\ Charles R Greathouse IV, Oct 14 2013
    
  • Python
    def A136480(n): return (~(m:=n+(n&1))& m-1).bit_length() # Chai Wah Wu, Jul 08 2022

Formula

a(n) = A050603(n-1) for n>0;
a(2*n + n mod 2) = a(n) + 1.
For n>0: a(n) = A007814(n + n mod 2).
Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=0..m} a(k) = 2. - Amiram Eldar, Sep 15 2022
a(n) = A007814(A002378(n)), n>0. - R. J. Mathar, Mar 20 2023