OFFSET
1,1
COMMENTS
Numbers n such that a(n) = 0: 13, 16, 19, 25, 28, 31, 40, 43, 46, 52, 55, 58, 61, 67, 73, 76, ...
a(n) = 0 if n == 1 (mod 3) and none of the pairs {n-1, 3n+1}, {2n-1, 4n+1}, {n+1, n+2} have both members prime. On Dickson's conjecture "if" can be replaced with "if and only if". - Charles R Greathouse IV, May 07 2013
Smallest k > 1 such that n^k - n - 1 and n^k + n + 1 are both prime, or 0 if no such k exists: 0, 3, 2, 0, 2, 2, 0, 3, 3, 0, 4, 2, 0, 2, 3, 0, 2, 3, 0, 2, 2, 0, ... - Juri-Stepan Gerasimov, May 09 2013
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
EXAMPLE
a(1) = 5 because 1*5 - 1 - 1 = 3 and 1*5 + 1 + 1 = 7 are both prime,
a(2) = 5 because 2*5 - 2 - 1 = 7 and 2*5 + 2 + 1 = 13 are both prime,
a(3) = 3 because 3*3 - 3 - 1 = 5 and 3*3 + 3 + 1 = 13 are both prime.
MATHEMATICA
a[n_] := Block[{p = 2}, If[n < 5, {5, 5, 3, 2}[[n]], If[Mod[n, 3] == 1, If[PrimeQ[2*n-1] && PrimeQ[4*n+1], 3, 0], While[! PrimeQ[n*(p - 1) -1] || ! PrimeQ[n*(p + 1) +1], p = NextPrime@p]; p]]]; Array[a, 80] (* Giovanni Resta, May 05 2013 *)
PROG
(PARI) a(n)=forprime(p=2, 5, if(isprime(n*p-n-1) && isprime(n*p+n+1), return(p))); if(n%3==1, return(0)); forprime(p=7, , if(isprime(n*p-n-1) && isprime(n*p+n+1), return(p))) \\ Charles R Greathouse IV, May 07 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
Juri-Stepan Gerasimov, May 05 2013
EXTENSIONS
Corrected by R. J. Mathar, May 05 2013
STATUS
approved