A127746
Smallest n-digit prime whose reversal is also prime.
Original entry on oeis.org
2, 13, 107, 1009, 10007, 100049, 1000033, 10000169, 100000007, 1000000007, 10000000207, 100000000237, 1000000000091, 10000000000313, 100000000000261, 1000000000000273, 10000000000000079, 100000000000000049
Offset: 1
-
f[n_] := Block[{k = 10^(n - 1), id, rid}, While[ id = IntegerDigits[k]; rid = Reverse[id]; ! PrimeQ[k] || ! PrimeQ[FromDigits[rid]] || id == rid, k++ ]; k]; Table[f[n], {n, 2, 19}] (* Ray Chandler, Jan 30 2007 *)
sndp[n_]:=Module[{np=NextPrime[10^(n+1)]},While[PalindromeQ[np] || !PrimeQ[ IntegerReverse[ np]],np= NextPrime[np]];np]; Join[{2},Array[sndp,20,0]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Mar 11 2017 *)
A127828
Largest n-digit emirp (A006567) with nonincreasing digits.
Original entry on oeis.org
97, 991, 9941, 99881, 999983, 9999971, 99999643, 999999761, 9999999511, 99999999977, 999999998863, 9999999998633, 99999999998333, 999999999999877, 9999999999998633, 99999999999987443, 999999999999999331, 9999999999999988633, 99999999999999999631
Offset: 2
-
nde[n_]:=Module[{p=NextPrime[10^n,-1]},While[Max[Differences[ IntegerDigits[ p]]]>0 || CompositeQ[IntegerReverse[p]],p=NextPrime[ p,-1]];p]; Array[nde,17,2] (* Harvey P. Dale, Mar 13 2020 *)
-
from sympy import isprime
from itertools import count, islice, combinations_with_replacement as mc
def bgen(d):
nd = ("".join(m) for m in mc("987654321", d))
yield from filter(isprime, map(int, nd))
def ok(ndp):
s = str(ndp)
return len(set(s)) != 1 and isprime(int(s[::-1]))
def agen():
yield from (next(filter(ok, bgen(d))) for d in count(2))
print(list(islice(agen(), 20))) # Michael S. Branicky, Jun 26 2022
A127748
Largest n-digit emirp (A006567) with strictly decreasing (distinct) digits.
Original entry on oeis.org
97, 983, 9871, 98731, 986543, 9875321
Offset: 2
Showing 1-3 of 3 results.
Comments