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.

A265526 Largest base-2 palindrome m <= n, written in base 2.

This page as a plain text file.
%I A265526 #10 Dec 09 2015 22:18:40
%S A265526 0,1,1,11,11,101,101,111,111,1001,1001,1001,1001,1001,1001,1111,1111,
%T A265526 10001,10001,10001,10001,10101,10101,10101,10101,10101,10101,11011,
%U A265526 11011,11011,11011,11111,11111,100001,100001,100001,100001,100001,100001,100001,100001,100001,100001,100001,100001,101101,101101,101101
%N A265526 Largest base-2 palindrome m <= n, written in base 2.
%p A265526 ispal:= proc(n) global b; # test for base-b palindrome
%p A265526   local L, Ln, i;
%p A265526   L:= convert(n, base, b);
%p A265526   Ln:= nops(L);
%p A265526 for i from 1 to floor(Ln/2) do
%p A265526 if L[i] <> L[Ln+1-i] then return(false); fi;
%p A265526 od:
%p A265526 return(true);
%p A265526 end proc;
%p A265526 # find max pal <= n, write in base 10
%p A265526 less10:=proc(n) global b;
%p A265526 local t1,t2,i,m,sw1,L2;
%p A265526 t1:=convert(n,base,b);
%p A265526 for m from n by -1 to 0 do
%p A265526 if ispal(m) then return(m); fi;
%p A265526                         od;
%p A265526 end proc;
%p A265526 # find max pal <= n, write in base b
%p A265526 lessb:=proc(n) global b;
%p A265526 local t1,t2,i,m,mb,sw1,L2;
%p A265526 t1:=convert(n,base,b);
%p A265526 for m from n by -1 to 0 do
%p A265526 if ispal(m) then
%p A265526    t2:=convert(m,base,b);
%p A265526    L2:=nops(t2);
%p A265526    mb:=add(t2[i]*10^(i-1), i=1..L2); return(mb); fi;
%p A265526                         od;
%p A265526 end proc;
%p A265526 b:=2;
%p A265526 [seq(less10(n),n=0..100)]; # A206913
%p A265526 [seq(lessb(n),n=0..100)]; # A265526
%p A265526 [seq(less10(2*n),n=0..100)]; # A265527
%p A265526 [seq(lessb(2*n),n=0..100)]; # A265528
%p A265526 b:=10;
%p A265526 [seq(less10(n),n=0..100)]; # A261423
%Y A265526 Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.
%K A265526 nonn,base
%O A265526 0,4
%A A265526 _N. J. A. Sloane_, Dec 09 2015