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.

A265543 a(n) = smallest base-2 palindrome m >= n such that every base-2 digit of n is <= the corresponding digit of m; m is written in base 2.

This page as a plain text file.
%I A265543 #13 Oct 15 2017 19:27:54
%S A265543 0,1,11,11,101,101,111,111,1001,1001,1111,1111,1111,1111,1111,1111,
%T A265543 10001,10001,11011,11011,10101,10101,11111,11111,11011,11011,11011,
%U A265543 11011,11111,11111,11111,11111,100001,100001,110011,110011,101101,101101,111111,111111,101101,101101,111111,111111,101101,101101,111111
%N A265543 a(n) = smallest base-2 palindrome m >= n such that every base-2 digit of n is <= the corresponding digit of m; m is written in base 2.
%p A265543 ispal:= proc(n) global b; # test if n is base-b palindrome
%p A265543   local L, Ln, i;
%p A265543   L:= convert(n, base, b);
%p A265543   Ln:= nops(L);
%p A265543 for i from 1 to floor(Ln/2) do
%p A265543 if L[i] <> L[Ln+1-i] then return(false); fi;
%p A265543 od:
%p A265543 return(true);
%p A265543 end proc;
%p A265543 # find min pal >= n and with n in base-b shadow, write in base 10
%p A265543 over10:=proc(n) global b;
%p A265543 local t1,t2,i,m,sw1,L1;
%p A265543 t1:=convert(n,base,b);
%p A265543 L1:=nops(t1);
%p A265543 for m from n to 10*n do
%p A265543 if ispal(m) then
%p A265543    t2:=convert(m,base,b);
%p A265543    sw1:=1;
%p A265543    for i from 1 to L1 do
%p A265543       if t1[i] > t2[i] then sw1:=-1; break; fi;
%p A265543                       od:
%p A265543    if sw1=1 then return(m); fi;
%p A265543 fi;
%p A265543                        od;
%p A265543 lprint("no solution in over10 for n = ", n);
%p A265543 end proc;
%p A265543 # find min pal >= n and with n in base-b shadow, write in base 10
%p A265543 overb:=proc(n) global b;
%p A265543 local t1,t2,i,m,mb,sw1,L1;
%p A265543 t1:=convert(n,base,b);
%p A265543 L1:=nops(t1);
%p A265543 for m from n to 10*n do
%p A265543 if ispal(m) then
%p A265543    t2:=convert(m,base,b);
%p A265543    sw1:=1;
%p A265543    for i from 1 to L1 do
%p A265543       if t1[i] > t2[i] then sw1:=-1; break; fi;
%p A265543                       od:
%p A265543    if sw1=1 then mb:=add(t2[i]*10^(i-1), i=1..nops(t2)); return(mb); fi;
%p A265543 fi;
%p A265543                        od;
%p A265543 lprint("no solution in over10 for n = ", n);
%p A265543 end proc;
%p A265543 b:=2;
%p A265543 [seq(over10(n),n=0..144)]; # A175298
%p A265543 [seq(overb(n),n=0..144)]; # A265543
%t A265543 sb2p[n_]:=Module[{m=n},While[!PalindromeQ[IntegerDigits[m,2]]|| Min[ IntegerDigits[ m,2]-IntegerDigits[n,2]]<0,m++];FromDigits[ IntegerDigits[ m,2]]]; Array[sb2p,50,0] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Oct 15 2017 *)
%Y A265543 Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.
%Y A265543 See A206913 for the values of m written in base 10.
%K A265543 nonn,base
%O A265543 0,3
%A A265543 _N. J. A. Sloane_, Dec 09 2015