login
A333770
Smallest palindromic number >= 3^n.
2
1, 3, 9, 33, 88, 252, 737, 2222, 6666, 19691, 59095, 177771, 532235, 1594951, 4783874, 14355341, 43055034, 129141921, 387424783, 1162332611, 3486886843, 10460406401, 31381118313, 94143234149, 282429924282, 847288882748
OFFSET
0,2
LINKS
FORMULA
a(n) = A262038(A000244(n)). - Michel Marcus, May 04 2020
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