close
login
A084015
Largest n-digit palindromic multiple of n. For n = 10k it is sufficient that the multiple is palindromic with leading zeros ignored. 0 if no such number exists.
6
9, 88, 999, 8888, 59995, 897798, 9994999, 88899888, 999999999, 9999999990, 99999799999, 889998899988, 9999990999999, 89999988999998, 599999989999995, 8889999999999888, 99999999199999999, 899999991199999998, 9999999974799999999, 89999999999999999980, 999999999969999999999, 8999999999999999999998
OFFSET
1,1
COMMENTS
Conjecture: no entry is zero.
LINKS
MAPLE
pal1:= proc(n) local L, i, d;
L:= convert(n, base, 10);
d:= nops(L);
add(L[i]*(10^(d-i)+10^(d+i-1)), i=1..d)
end proc:
pal2:= proc(n) local L, i, d;
L:= convert(n, base, 10);
d:= nops(L);
add(L[i]*(10^(d-i)+10^(d+i-2)), i=2..d)+10^(d-1)*L[1]
end proc:
rev:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
for m from 1 to 9 do A2[m]:= sort(map(rev, select(t -> t mod 10 <> 0, [seq(i, i=10^m .. 10^(m-1), -2^m)])), `>`) od:
for m from 1 to 4 do A5[m]:= sort(map(rev, select(t -> t mod 10 <> 0, [seq(i, i=10^m .. 10^(m-1), -5^m)])), `>`) od:
f:= proc(n) local r, m, nr, pal, nr2, a2, a, b, x, a5;
r:= padic:-ordp(n, 10);
nr:= n-r; m:= n/10^r;
if nr::even then pal:= pal1 else pal:= pal2 fi;
nr2:= ceil(nr/2);
if m::even then
a2:= padic:-ordp(m, 2);
for a in A2[a2] do
for b from 10^(nr2-a2)-1 to 0 by -1 do
x:= pal(10^(nr2-a2)*a + b)*10^r;
if x mod n = 0 then return x fi
od od
elif m mod 5 = 0 then
a5:= padic:-ordp(m, 5);
for a in A5[a5] do
for b from 10^(nr2-a5)-1 to 0 by -1 do
x:= pal(10^(nr2-a5)*a + b)*10^r;
if x mod n = 0 then return x fi
od od
else
for a from 10^(nr2)-1 to 10^(nr2-1) by -1 do
x:= pal(a)*10^r;
if x mod n = 0 then return x fi
od
fi;
0
end proc:
msp(f, [$1..100]); # Robert Israel, Aug 24 2025
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy and Meenakshi Srikanth (menakan_s(AT)yahoo.com), May 23 2003
EXTENSIONS
Corrected and extended by Ray Chandler, Jun 08 2003
a(17) corrected and more terms from Robert Israel, Aug 25 2025
STATUS
approved