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.

Showing 1-2 of 2 results.

A114018 Least n-digit prime whose digit reversal is also prime.

Original entry on oeis.org

2, 11, 101, 1009, 10007, 100049, 1000033, 10000169, 100000007, 1000000007, 10000000207, 100000000237, 1000000000091, 10000000000313, 100000000000261, 1000000000000273, 10000000000000079, 100000000000000049, 1000000000000002901, 10000000000000000051
Offset: 1

Views

Author

Amarnath Murthy, Nov 12 2005

Keywords

Comments

The more compact version A168159 gives many more terms, cf. formula. [M. F. Hasler, Nov 21 2009]

Crossrefs

Cf. A168159, A007500, A006567, A122490. [M. F. Hasler, Nov 21 2009]

Programs

  • Mathematica
    f[n_] := Block[{k = 10^(n - 1)}, While[ !PrimeQ[k] || !PrimeQ[FromDigits@Reverse@IntegerDigits@k], k++ ]; k]; Array[f, 19] (* Robert G. Wilson v, Nov 19 2005 *)
    lndp[n_]:=Module[{p=NextPrime[10^n]},While[CompositeQ[IntegerReverse[ p]],p = NextPrime[ p]];p]; Array[lndp,20,0] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 05 2019 *)
  • PARI
    for(x=1,1e99, until( isprime(x=nextprime(x+1)) & isprime(eval(concat(vecextract(Vec(Str(x)),"-1..1")))),); print1(x", "); x=10^#Str(x)-1) \\ M. F. Hasler, Nov 21 2009
    
  • 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) if c(p))
    print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Jun 27 2022

Formula

a(n) = 10^(n-1) + A168159(n). [M. F. Hasler, Nov 21 2009]

Extensions

More terms from Robert G. Wilson v, Nov 19 2005

A168159 Distance of the least reversible n-digit prime from 10^(n-1).

Original entry on oeis.org

1, 1, 1, 9, 7, 49, 33, 169, 7, 7, 207, 237, 91, 313, 261, 273, 79, 49, 2901, 51, 441, 193, 9, 531, 289, 1141, 67, 909, 331, 753, 2613, 657, 49, 4459, 603, 1531, 849, 2049, 259, 649, 2119, 1483, 63, 6747, 519, 3133, 937, 1159, 1999, 6921, 2949, 613, 4137, 1977, 31
Offset: 1

Views

Author

M. F. Hasler, Nov 21 2009

Keywords

Comments

A (much) more compact form of A114018 (cf. formula). Since this sequence and A114018 refer to "reversible primes" (A007500), while A122490 seems to use "emirps" (A006567), a(n+1) differs from A122490(n) iff 10^n+1 is prime <=> a(n+1)=1 <=> A114018(n)=10^n+1.

Programs

  • Mathematica
    Table[p = NextPrime[y = 10^(n - 1)]; While[! PrimeQ[FromDigits[Reverse[IntegerDigits[p]]]], p = NextPrime[p]]; p - y, {n, 55}] (* Jayanta Basu, Aug 09 2013 *)
  • PARI
    for(x=1,1e99, until( isprime(x=nextprime(x+1)) & isprime(eval(concat(vecextract(Vec(Str(x)),"-1..1")))),);print1(x-10^ (#Str(x)-1),", "); x=10^#Str(x)-1)
    
  • Python
    from sympy import isprime
    def c(n): return isprime(n) and isprime(int(str(n)[::-1]))
    def a(n): return next(p-10**(n-1) for p in range(10**(n-1), 10**n) if c(p))
    print([a(n) for n in range(1, 56)]) # Michael S. Branicky, Jun 27 2022

Formula

a(n)=A114018(n)-10^(n-1)
Showing 1-2 of 2 results.