OFFSET
1,1
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..100
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
KEYWORD
AUTHOR
J. M. Bergot and Robert Israel, May 30 2019
STATUS
approved