A329457 Least positive integer x such that both n*x + n + x and n*x - n - x are primes, or -1 if no such x exists.
5, 4, 3, 2, 5, 2, 7, 2, 3, 3, 13, 2, 9, 2, 3, 3, 5, 2, 3, 4, 5, 6, 7, 3, 9, 5, 5, 4, 13, 3, 3, 2, 9, 4, 11, 3, 21, 4, 9, 3, 5, 2, 7, 2, 5, 4, 17, 2, 19, 5, 3, 7, 7, 2, 3, 5, 5, 7, 7, 8, 19, 2, 5, 3, 23, 3, 15, 5, 3, 6, 19, 11, 67, 2, 3, 3, 7, 5, 9, 4, 9, 6, 5, 2, 13, 4
Offset: 2
Keywords
Examples
5 is the least positive integer x such that both 2*x + 2 + x = 17 and 2*x - 2 - x = 3 are primes. Therefore a(2) = 5.
Programs
-
Mathematica
Array[Block[{x = 1}, While[! AllTrue[# x + {-1, 1} (# + x), PrimeQ], x++]; x] &, 86, 2] (* Michael De Vlieger, Dec 27 2019 *)
-
PARI
a(n) = my(x=1); while (!isprime(n*x + n + x) || !isprime(n*x - n - x), x++); x; \\ Michel Marcus, Nov 14 2019