OFFSET
1,1
PROG
(Python)
from sympy import isprime, nextprime
from sympy.ntheory import digits
def A371509(n):
if n == 1: return 2
p, r = 5, (n<<1)+1
while True:
m = 1
for j in digits(p, r)[:0:-1]:
for k in range(2-(j&1), r, 2):
if k!=j and isprime(p+(k-j)*m):
break
else:
m *= r
continue
break
else:
return p
p = nextprime(p)
CROSSREFS
KEYWORD
nonn,more,base
AUTHOR
Chai Wah Wu, Mar 25 2024
STATUS
approved