login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
0

%I #15 Jan 16 2020 05:22:24

%S 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,

%T 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,

%U 23,3,15,5,3,6,19,11,67,2,3,3,7,5,9,4,9,6,5,2,13,4

%N 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.

%e 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.

%t Array[Block[{x = 1}, While[! AllTrue[# x + {-1, 1} (# + x), PrimeQ], x++]; x] &, 86, 2] (* _Michael De Vlieger_, Dec 27 2019 *)

%o (PARI) a(n) = my(x=1); while (!isprime(n*x + n + x) || !isprime(n*x - n - x), x++); x; \\ _Michel Marcus_, Nov 14 2019

%Y Cf. A000040, A196660.

%K nonn

%O 2,1

%A _Alex Ratushnyak_, Nov 13 2019