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

This page as a plain text file.
%I A215467 #17 Aug 12 2012 18:57:30
%S A215467 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,
%T A215467 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,
%U A215467 5,5,5,5,4,7,4,4,4,4,4,4,3,3,3,3,5,7,5,5,3,3,6
%N A215467 Length of longest palindromic prefix of (n base 2).
%C A215467 Since the binary expansion of n always begins with a 1, a final 0 can't affect the result, so a(2n) = a(n).
%H A215467 N. J. A. Sloane, <a href="/A215467/b215467.txt">Table of n, a(n) for n = 0..10000</a>
%e A215467 ...
%e A215467 4 = 100 -> 1
%e A215467 5 = 101 -> 3
%e A215467 6 = 110 -> 2
%e A215467 7 = 111 -> 3
%e A215467 8 = 1000 -> 1
%e A215467 9 = 1001 -> 4
%e A215467 ...
%p A215467 rev := proc(lis)
%p A215467     local t1,n,i;
%p A215467     t1:=[]; n:=nops(lis);
%p A215467     for i from 1 to n do t1:=[op(t1),lis[n+1-i]]; end do;
%p A215467     return t1;
%p A215467 end proc;
%p A215467 isPal := proc(L)
%p A215467     local d ;
%p A215467     for d from 1 to nops(L)/2 do
%p A215467         if op(d, L) <> op(-d, L) then
%p A215467             return false;
%p A215467         end if;
%p A215467     end do:
%p A215467     return true;
%p A215467 end proc:
%p A215467 A215467L := proc(L)
%p A215467     local a, c;
%p A215467     a := 1 ;
%p A215467     for c from 2 to nops(L) do
%p A215467         if isPal( [op(1..c, L)] ) then
%p A215467             a := c ;
%p A215467         end if;
%p A215467     end do:
%p A215467     return a;
%p A215467 end proc:
%p A215467 A215467 := proc(n)
%p A215467     if n <= 1 then 1;
%p A215467     else rev(convert(n, base, 2)) ;
%p A215467         A215467L(%) ;
%p A215467     end if;
%p A215467 end proc:
%Y A215467 Cf. A050430, A215469.
%K A215467 nonn,base
%O A215467 0,4
%A A215467 _N. J. A. Sloane_, Aug 11 2012