OFFSET
2,1
LINKS
Robert Israel, Table of n, a(n) for n = 2..10000
MAPLE
f:= proc(n) local d, S, j, q, x0, t, r, x;
for d from 2 do
S[ceil(d/2)+1]:= {0}:
for j from ceil(d/2) to 1 by -1 do
if j = (d+1)/2 then q:= 10^(j-1)
else q:= 10^(j-1)+10^(d-j)
fi;
if j = 1 then x0:= 1 else x0:= 0 fi;
S[j]:= {seq(seq(x*q+s mod n, x=x0..9), s=S[j+1])};
od;
if member(1, S[1]) then
t:= 1; r:= 0;
for j from 1 to ceil(d/2) do
if j = (d+1)/2 then q:= 10^(j-1) else q:= 10^(j-1)+10^(d-j) fi;
if j = 1 then x0:= 1 else x0:= 0 fi;
for x from x0 to 9 do
if member(t - x*q mod n, S[j+1]) then
r:= r + x*q;
t:= t - x*q mod n;
break
fi
od;
od;
return r
fi
od
end proc:
$3..9, seq(f(n), n=9..100); # Robert Israel, Dec 17 2019
MATHEMATICA
With[{pals=Select[Range[2, 11000], PalindromeQ]}, Table[SelectFirst[pals, Mod[#, n]==1&], {n, 2, 60}]] (* Harvey P. Dale, Dec 03 2023 *)
CROSSREFS
KEYWORD
AUTHOR
Amarnath Murthy, Nov 08 2002
EXTENSIONS
Corrected and extended by Ray Chandler, Aug 20 2003
STATUS
approved