A114019 Largest n-digit prime whose digit reversal is also prime.
7, 97, 991, 9967, 99989, 999983, 9999971, 99999827, 999999893, 9999999967, 99999999977, 999999999959, 9999999999799, 99999999999959, 999999999999877, 9999999999999571, 99999999999997997, 999999999999999737, 9999999999999999719, 99999999999999999631
Offset: 1
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..527
Crossrefs
Cf. A113018.
Programs
-
Mathematica
f[n_] := Block[{k = 10^n}, While[ !PrimeQ[k] || !PrimeQ[FromDigits@Reverse@IntegerDigits@k], k-- ]; k]; Array[f, 19] (* Robert G. Wilson v, Nov 19 2005 *) Table[Module[{p=NextPrime[10^e,-1]},While[CompositeQ[IntegerReverse[p]],p=NextPrime[p,-1]];p],{e,20}] (* Harvey P. Dale, Mar 01 2025 *)
-
Python
from sympy import isprime def c(n): return isprime(n) and isprime(int(str(n)[::-1])) def a(n): return next(p for p in range(10**n-1, 10**(n-1), -2) if c(p)) print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Jun 27 2022
Extensions
More terms from Robert G. Wilson v, Nov 19 2005
a(19) and beyond from Michael S. Branicky, Jun 27 2022