login
Smallest prime q such that (q^p+1)/(q+1) is prime, where p = prime(n); or 0 if no such prime q exists.
8

%I #13 Aug 01 2019 20:25:28

%S 0,2,2,2,2,2,2,2,2,7,2,19,61,2,7,839,89,2,5,409,571,2,809,227,317,2,5,

%T 79,23,4073,2,281,89,739,1427,727,19,19,2,281,11,2143,2,1013,4259,2,

%U 661,1879,401,5,4099,1579,137,43,487,307,547,1709,43,3,463,2161,353,443,2

%N Smallest prime q such that (q^p+1)/(q+1) is prime, where p = prime(n); or 0 if no such prime q exists.

%C a(1) = 0 because such a prime does not exist, Mod[n^2+1,n+1] = 2 for n>1.

%C Corresponding primes (q^p+1)/(q+1), where prime q = a(n) and p = Prime[n], are listed in A123628[n] = {1,3,11,43,683,2731,43691,174763,2796203,402488219476647465854701,715827883,...}.

%C a(n) coincides with A103795[n] when A103795[n] is prime.

%C a(n) = 2 for n = PrimePi[A000978[k]] = {2,3,4,5,6,7,8,9,11,14,18,22,26,31,39,43,46,65,69,126,267,380,495,762,1285,1304,1364,1479,1697,4469,8135,9193,11065,11902,12923,13103,23396,23642,31850,...}.

%C Corresponding primes of the form (2^p + 1)/3 are the Wagstaff primes that are listed in A000979[n] = {3,11,43,683,2731,43691,174763,2796203,715827883,...}.

%H Robert Israel, <a href="/A123627/b123627.txt">Table of n, a(n) for n = 1..240</a>

%F A123628(n) = (a(n)^prime(n) + 1) / (a(n) + 1).

%p f:= proc(n) local p,q;

%p p:= ithprime(n);

%p q:= 1;

%p do

%p q:= nextprime(q);

%p if isprime((q^p+1)/(q+1)) then return q fi

%p od

%p end proc:

%p f(1):= 0:

%p map(f, [$1..70]); # _Robert Israel_, Jul 31 2019

%t a(1) = 0, for n>1 Do[p=Prime[k]; n=1; q=Prime[n]; cp=(q^p+1)/(q+1); While[ !PrimeQ[cp], n=n+1; q=Prime[n]; cp=(q^p+1)/(q+1)]; Print[q], {k, 2, 61}]

%t Do[p=Prime[k]; n=1; q=Prime[n]; cp=(q^p+1)/(q+1); While[ !PrimeQ[cp], n=n+1; q=Prime[n]; cp=(q^p+1)/(q+1)]; Print[{k,q}], {k, 1, 134}]

%t spq[n_]:=Module[{p=Prime[n],q=2},While[!PrimeQ[(q^p+1)/(q+1)],q=NextPrime[ q]]; q]; Join[{0},Array[spq,70,2]] (* _Harvey P. Dale_, Mar 23 2019 *)

%Y Cf. A123628, A103795, A123487, A123488, A000978, A000979.

%K nonn

%O 1,2

%A _Alexander Adamchuk_, Oct 04 2006, Aug 05 2008