A215467 Length of longest palindromic prefix of (n base 2).
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
Examples
... 4 = 100 -> 1 5 = 101 -> 3 6 = 110 -> 2 7 = 111 -> 3 8 = 1000 -> 1 9 = 1001 -> 4 ...
Links
- N. J. A. Sloane, Table of n, a(n) for n = 0..10000
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:
Comments