login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
2
0, 1, 11, 11, 101, 101, 111, 111, 1001, 1001, 1111, 1111, 1111, 1111, 1111, 1111, 10001, 10001, 11011, 11011, 10101, 10101, 11111, 11111, 11011, 11011, 11011, 11011, 11111, 11111, 11111, 11111, 100001, 100001, 110011, 110011, 101101, 101101, 111111, 111111, 101101, 101101, 111111, 111111, 101101, 101101, 111111
OFFSET
0,3
MAPLE
ispal:= proc(n) global b; # test if n is base-b palindrome
local L, Ln, i;
L:= convert(n, base, b);
Ln:= nops(L);
for i from 1 to floor(Ln/2) do
if L[i] <> L[Ln+1-i] then return(false); fi;
od:
return(true);
end proc;
# find min pal >= n and with n in base-b shadow, write in base 10
over10:=proc(n) global b;
local t1, t2, i, m, sw1, L1;
t1:=convert(n, base, b);
L1:=nops(t1);
for m from n to 10*n do
if ispal(m) then
t2:=convert(m, base, b);
sw1:=1;
for i from 1 to L1 do
if t1[i] > t2[i] then sw1:=-1; break; fi;
od:
if sw1=1 then return(m); fi;
fi;
od;
lprint("no solution in over10 for n = ", n);
end proc;
# find min pal >= n and with n in base-b shadow, write in base 10
overb:=proc(n) global b;
local t1, t2, i, m, mb, sw1, L1;
t1:=convert(n, base, b);
L1:=nops(t1);
for m from n to 10*n do
if ispal(m) then
t2:=convert(m, base, b);
sw1:=1;
for i from 1 to L1 do
if t1[i] > t2[i] then sw1:=-1; break; fi;
od:
if sw1=1 then mb:=add(t2[i]*10^(i-1), i=1..nops(t2)); return(mb); fi;
fi;
od;
lprint("no solution in over10 for n = ", n);
end proc;
b:=2;
[seq(over10(n), n=0..144)]; # A175298
[seq(overb(n), n=0..144)]; # A265543
MATHEMATICA
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 *)
CROSSREFS
Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.
See A206913 for the values of m written in base 10.
Sequence in context: A215256 A265526 A265559 * A062128 A286618 A290206
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Dec 09 2015
STATUS
approved