OFFSET
0,2
LINKS
Robert Israel, Table of n, a(n) for n = 0..2093
FORMULA
EXAMPLE
a(10) = 59095, because 3^10 = 59049 and 59095 is the smallest palindromic number >= 59049.
MAPLE
digrev:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
f:= proc(n) local d, x, y, t;
d:= ilog10(n)+1;
if d::even then
x:= floor(n/10^(d/2));
t:= x*10^(d/2)+digrev(x);
if t >= n then return t fi;
(x+1)*10^(d/2)+digrev(x+1);
else
x:= floor(n/10^((d-1)/2));
t:= x*10^((d-1)/2)+digrev(floor(x/10));
if t >= n then return t fi;
y:= x mod 10;
if y < 9 then return t + 10^((d-1)/2) fi;
x:= x+1;
x*10^((d-1)/2)+digrev(floor(x/10));
fi
end proc:
seq(f(3^i), i=0..30); # Robert Israel, May 04 2020
PROG
(PARI) a(n) = for(k=3^n, oo, if(Vecrev(v=digits(k))==v, return(k)));
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Eder Vanzei, Apr 04 2020
STATUS
approved