login
A308438
a(n) is the smallest prime p whose decimal expansion begins with n and is such that the next prime is p+2n, or -1 if no such prime exists.
1
11, 223, 31, 401, 547, 619, 773, 8581, 9109, 10223, 1129, 12073, 130553, 14563, 150011, 161471, 17257, 18803, 191189, 20809, 210557, 225383, 237091, 240209, 2509433, 2613397, 277429, 283211, 2901649, 308153, 313409, 3204139, 3300613, 3419063, 3507739, 360091, 3727313, 3806347, 3930061, 4045421, 41018911
OFFSET
1,1
LINKS
EXAMPLE
For n = 5, 547 is a prime starting with 5, and the next prime after 547 is 557 = 547 + 2*5. Since this is the least number with these properties, a(5) = 547.
MAPLE
f:= proc(n) local d, p, q;
for d from 0 do
p:= nextprime(n*10^d-1);
do
q:= nextprime(p);
if q - p = 2*n then return p fi;
if q >= (n+1)*10^d then break fi;
p:= q;
od;
od;
end proc:
map(f, [$1..50]);
PROG
(Python)
from sympy import nextprime
def A308438(n):
l, p = 1, nextprime(n)
while True:
q = nextprime(p)
if q-p == 2*n:
return p
p = q
if p >= (n+1)*l:
l *= 10
p = nextprime(n*l) # Chai Wah Wu, May 31 2019
CROSSREFS
Sequence in context: A048377 A192686 A323416 * A103611 A142541 A295542
KEYWORD
nonn,base,look
AUTHOR
J. M. Bergot and Robert Israel, May 30 2019
STATUS
approved