login
A077528
a(n) = smallest nontrivial (>1) palindrome == 1 (mod n).
2
3, 4, 5, 6, 7, 8, 9, 55, 11, 111, 121, 66, 99, 121, 33, 171, 55, 77, 101, 22, 111, 323, 121, 101, 131, 55, 141, 88, 121, 373, 33, 232, 171, 141, 181, 1111, 77, 313, 121, 575, 505, 44, 353, 181, 323, 424, 1441, 99, 101, 868, 313, 10601, 55, 111, 393, 343, 929, 414
OFFSET
2,1
LINKS
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
Cf. A002113.
Sequence in context: A051415 A037351 A293727 * A329254 A359003 A183296
KEYWORD
base,nonn,look
AUTHOR
Amarnath Murthy, Nov 08 2002
EXTENSIONS
Corrected and extended by Ray Chandler, Aug 20 2003
STATUS
approved