A030540 Largest n-digit norep emirp.
7, 97, 983, 9871, 98731, 987361, 9876023, 98762051, 987653201
Offset: 1
Links
- C. K. Caldwell, Prime Curios, Entry 987653201
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.
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 *)
nextl:= proc(L) local m,k,r; # L a list of digits 1-9, last odd, in nondecreasing order if L[-1]<= 7 then return subsop(-1=L[-1]+2, L) fi; m:= nops(L); k:= m-1; while L[k] =9 do k:= k-1 od: r:= [op(L[1..k-1]),(L[k]+1) $ (m+1-k)]; if r[-1]::even then r:= subsop(-1=r[-1]+1, r) fi; r end proc: f:= proc(n) local L,p,q,i; L:= [1$n]; do p:= add(L[i]*10^(i-1),i=1..n); q:= add(L[-i]*10^(i-1),i=1..n); if q <> p and isprime(p) and isprime(q) then return(q) fi; L:= nextl(L); od end proc: map(f, [$2..30]); # Robert Israel, Nov 19 2017
from sympy import isprime from itertools import count, islice, combinations_with_replacement as mc def bgen(d): nd = ("".join(m) for m in mc("123456789", 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(), 22))) # Michael S. Branicky, Jun 26 2022
There are 12 norep emirps less than 100
Comments