OFFSET
1,1
COMMENTS
Previous name: Smallest prime whose decimal expansion begins (nontrivially) with the n-th prime.
Add digits to p (starting with a nonzero digit) until another prime is reached.
This differs from A064792 in that there the appended digits may start with a 0. The first difference occurs at a(16) = 5323, while A064792(16) = 5303. - M. F. Hasler, Jan 15 2025
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(16) = 5323 because 53 is the 16th prime, and 23 is the smallest number that can be appended to 53 to give another prime. 5303 is not allowed because 03 starts with zero. - David Radcliffe, Jan 08 2025
MAPLE
f:= proc(p) local d, x;
for d from 1 do
x:= nextprime(10^d*p+10^(d-1)-1);
if x < 10^d*(p+1) then return x fi
od
end proc:
map(f @ ithprime, [$1..100]); # Robert Israel, Aug 12 2018
MATHEMATICA
f[n_] := Block[{k = 1, p = Prime@ n}, While[a = 10^Floor[1 + Log10@ k] p + k; !PrimeQ@ a, k += 2]; a]; Array[f, 44]
PROG
(Python)
from sympy import prime, isprime
from itertools import count
def a030670(n):
p = str(prime(n))
return next(x for k in count(1) if isprime(x:=int(p+str(k)))) # David Radcliffe, Jan 08 2025
(PARI) apply( {A030670(n)=n=prime(n); for(L=1, oo, n*=10; forstep(s=bitor(10^(L-1), 1), 10^L-1, 2, isprime(n+s)&& return(n+s)))}, [1..44]) \\ M. F. Hasler, Jan 15 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Title changed by David Radcliffe, Jan 08 2025
STATUS
approved