OFFSET
1,1
COMMENTS
Diagonal of triangle A114009.
LINKS
Robert Israel, Table of n, a(n) for n = 1..4000
MAPLE
f:= proc(n) local p, q, d, count, i;
p:= ithprime(n); count:= 1;
for d from 1 do
q:= 10^d*p;
for i from count do
q:= nextprime(q);
if q > 10^d*(p+1) then break fi;
count:= count+1;
if count = n then return q fi;
od od;
end proc:
f(1):= 2:
map(f, [$1..100]); # Robert Israel, Jan 19 2023
PROG
(PARI) ok(np, dfp) = {dnp = digits(np); xdnp = vector(#dfp, id, dnp[id]); xdnp == dfp; }
findnextp(p, dfp) = {np = nextprime(p+1); while (! ok(np, dfp), np = nextprime(np+1)); np; }
a(n) = {p = fp = prime(n); dfp = digits(fp); for (k = 2, n, p = findnextp(p, dfp); ); p; } \\ Michel Marcus, Sep 16 2013
(Python)
from itertools import count
from sympy import isprime, prime
def a(n):
if n == 1: return 2
pn, c = prime(n), 1
for d in count(1):
pow10 = 10**d
base = pn * pow10
for i in range(1, pow10, 2):
t = base + i
if isprime(t): c += 1
if c == n: return t
print([a(n) for n in range(1, 41)]) # Michael S. Branicky, Jan 19 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Michel Marcus, Sep 16 2013
STATUS
approved