A341932 a(n) = largest k < n such that the decimal concatenation n||n-1||n-2||...||n-k is prime, or -1 if no such prime exists.
-1, -1, 0, 0, 1, 0, -1, 4, -1, -1, 3, 0, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, 3, 0, 1, 12, -1, 4, -1, 0, -1, 0, -1, -1, 1, -1, -1, 0, -1, -1, -1, 0, 1, 0, -1, -1, 43, 0, 31, -1, -1, 4, 15, 12, -1, 28, 9, -1, 1, 0, 13, 0, -1, -1, -1, -1, -1, 0, 57, -1, 1, 0, -1
Offset: 0
Examples
a(22) = 3 since 22212019 is prime.
Programs
-
Python
from sympy import isprime def A341932(n): k, m, r = n, n-1, 0 if isprime(n) else -1 while m > 0: k = int(str(k)+str(m)) if isprime(k): r = n-m m -= 1 return r
Comments