login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A215467 Length of longest palindromic prefix of (n base 2). 5
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,4

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).

LINKS

N. J. A. Sloane, Table of n, a(n) for n = 0..10000

EXAMPLE

...

4 = 100 -> 1

5 = 101 -> 3

6 = 110 -> 2

7 = 111 -> 3

8 = 1000 -> 1

9 = 1001 -> 4

...

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:

CROSSREFS

Cf. A050430, A215469.

Sequence in context: A097285 A057432 A302295 * A284266 A317988 A038568

Adjacent sequences:  A215464 A215465 A215466 * A215468 A215469 A215470

KEYWORD

nonn,base

AUTHOR

N. J. A. Sloane, Aug 11 2012

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 14 17:07 EDT 2022. Contains 356122 sequences. (Running on oeis4.)