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.

A089310 Write n in binary; a(n) = number of 1's in second block of 1's from right.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Dec 22 2003

Keywords

Examples

			13 = 1101 so a(13) = 2.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local t,q,r;
      r:= 0: t:= n;
      while t::even do t:= t/2 od;
      while t::odd do t:= (t-1)/2 od;
      if t = 0 then return 0 fi;
      while t::even do t:= t/2 od;
      while t::odd do r:= r+1; t:= (t-1)/2 od;
      r
    end proc:
    f(0):= 0:
    map(f, [$0..100]); # Robert Israel, Aug 03 2025
  • PARI
    a(n)=my(b, c, s); if(n==0,return(0)); b=binary(n); c=length(b); while(!b[c], c=c-1); while(c>0&&b[c], c=c-1); if(c<=0, 0, while(!b[c], c=c-1); s=0; while(c>0&&b[c], c=c-1;s=s+1);s) /* Ralf Stephan, Feb 01 2004 */

Extensions

More terms from Ralf Stephan, Feb 01 2004