cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A383887 Smallest non-palindromic number that is congruent to its reverse mod n.

This page as a plain text file.
%I A383887 #98 Jun 04 2025 10:24:38
%S A383887 10,13,10,15,16,13,18,19,10,1011,100,15,1017,1027,16,1025,1039,13,
%T A383887 1048,1021,18,103,1026,19,1026,1017,14,1033,1013,1011,1068,1049,100,
%U A383887 1039,1046,15,1000,1055,1017,1041,1066,1027,1048,105,16,1077,1032,1025,1014,1051,1039,1017,1103,17,106,1065
%N A383887 Smallest non-palindromic number that is congruent to its reverse mod n.
%C A383887 Comparable to A070837, but such a number provably exists: if n is coprime to 10 then take 10^k where k is the order of 10 mod n; else take a>b>0 such that n divides 10^a - 10^b, then the number 10^(a+b) + 10^b + 1 works.
%C A383887 The n-th term in this sequence is equal to the first nonzero term of A070837 that occurs at an index divisible by n/gcd(n,9).
%H A383887 Erick B. Wong, <a href="/A383887/b383887.txt">Table of n, a(n) for n = 1..10000</a>
%e A383887 For n=6, a(6)=13 is congruent to 31 mod 6.
%e A383887 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.
%t A383887 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 *)
%o A383887 (Python)
%o A383887 from functools import partial
%o A383887 from itertools import count
%o A383887 def accept(mod, k):
%o A383887     r = int(str(k)[::-1])
%o A383887     return r != k and (r-k) % mod == 0
%o A383887 def a(n):
%o A383887     return next(filter(partial(accept, n), count(10)))
%o A383887 print([a(n) for n in range(1,57)])
%o A383887 (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
%Y A383887 Cf. A004086, A056965, A070837.
%K A383887 nonn,base,easy
%O A383887 1,1
%A A383887 _Erick B. Wong_, May 29 2025, at the suggestion of Lanny Wong