A383887 Smallest non-palindromic number that is congruent to its reverse mod n.
10, 13, 10, 15, 16, 13, 18, 19, 10, 1011, 100, 15, 1017, 1027, 16, 1025, 1039, 13, 1048, 1021, 18, 103, 1026, 19, 1026, 1017, 14, 1033, 1013, 1011, 1068, 1049, 100, 1039, 1046, 15, 1000, 1055, 1017, 1041, 1066, 1027, 1048, 105, 16, 1077, 1032, 1025, 1014, 1051, 1039, 1017, 1103, 17, 106, 1065
Offset: 1
Examples
For n=6, a(6)=13 is congruent to 31 mod 6. For n=10, note that any number of 3 or fewer digits is necessarily a palindrome if the first digit equals the last, and 1011 is the first 4-digit non-palindrome.
Links
- Erick B. Wong, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
seq[len_] := Module[{s = Table[0, {len}], c = 0, k = 9, d}, While[c < len, k++; krev = IntegerReverse[k]; If[k != krev, d = Select[Divisors[Abs[k - krev]], # <= len &]; Do[If[s[[d[[i]]]] == 0, s[[d[[i]]]] = k; c++], {i, 1, Length[d]}]]]; s]; seq[60] (* Amiram Eldar, May 31 2025 *)
-
PARI
a(n) = my(k=1, d=digits(k), rd=Vecrev(d)); while(!((d != rd) && Mod(fromdigits(rd), n) == k), k++; d=digits(k); rd=Vecrev(d)); k; \\ Michel Marcus, May 30 2025
-
Python
from functools import partial from itertools import count def accept(mod, k): r = int(str(k)[::-1]) return r != k and (r-k) % mod == 0 def a(n): return next(filter(partial(accept, n), count(10))) print([a(n) for n in range(1,57)])
Comments