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.

A215467 Length of longest palindromic prefix of (n base 2).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Aug 11 2012

Keywords

Comments

Since the binary expansion of n always begins with a 1, a final 0 can't affect the result, so a(2n) = a(n).

Examples

			...
4 = 100 -> 1
5 = 101 -> 3
6 = 110 -> 2
7 = 111 -> 3
8 = 1000 -> 1
9 = 1001 -> 4
...
		

Crossrefs

Programs

  • Maple
    rev := proc(lis)
        local t1,n,i;
        t1:=[]; n:=nops(lis);
        for i from 1 to n do t1:=[op(t1),lis[n+1-i]]; end do;
        return t1;
    end proc;
    isPal := proc(L)
        local d ;
        for d from 1 to nops(L)/2 do
            if op(d, L) <> op(-d, L) then
                return false;
            end if;
        end do:
        return true;
    end proc:
    A215467L := proc(L)
        local a, c;
        a := 1 ;
        for c from 2 to nops(L) do
            if isPal( [op(1..c, L)] ) then
                a := c ;
            end if;
        end do:
        return a;
    end proc:
    A215467 := proc(n)
        if n <= 1 then 1;
        else rev(convert(n, base, 2)) ;
            A215467L(%) ;
        end if;
    end proc: