[go: up one dir, main page]

login
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
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
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
Sequence in context: A374741 A361942 A302295 * A284266 A317988 A038568
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Aug 11 2012
STATUS
approved