login
a(n) = (p+1)/2 if 4 | p+1, and p otherwise, where p is the least prime > n with 2(n+1)-p prime.
1

%I #17 May 30 2016 11:31:54

%S 2,2,5,5,4,4,6,6,13,6,13,13,17,17,10,17,10,10,12,12,16,12,29,16,29,16,

%T 37,29,16,16,41,37,37,41,41,37,24,41,22,41,22,22,24,24,61,24,53,61,53,

%U 30,61,53,61,34,30,61,73,30,61,61,36,34,34,36,36,34,42,36,73,36,73,73,89,40,40,42,42,40,89,42,97,42,89,97,89,101,97,89,97,52,101,97,109,101,52,97,54,101,52,101

%N a(n) = (p+1)/2 if 4 | p+1, and p otherwise, where p is the least prime > n with 2(n+1)-p prime.

%C Conjecture: If b(1)>2 is an integer, and b(k+1)=a(b(k)) for k=1,2,3,..., then b(n)=4 for some n>0.

%C For example, if we start from b(1)=45 then we get the sequence 45, 61, 36, 37, 24, 16, 17, 10, 6, 4, 5, 4, ...

%H Zhi-Wei Sun, <a href="/A213187/b213187.txt">Table of n, a(n) for n = 1..10000</a>

%H Zhi-Wei Sun, <a href="http://arxiv.org/abs/1211.1588">Conjectures involving primes and quadratic forms</a>, arXiv:1211.1588.

%e a(8)=6 since 2(8+1)=11+5 with (11+1)/2=6;

%e a(9)=13 since 2(9+1)=13+7.

%t Do[Do[If[PrimeQ[2n+2-Prime[k]]==True,Print[n," ",If[Mod[Prime[k],4]==3,(Prime[k]+1)/2,Prime[k]]];Goto[aa]],{k,PrimePi[n]+1,PrimePi[2n]}];

%t Label[aa];Continue,{n,1,100}]

%t nxt[{n_,a_}]:=Module[{p=NextPrime[n]},While[!PrimeQ[2(n+1)-p],p = NextPrime[ p]];{n+1,If[Divisible[p+1,4],(p+1)/2,p]}]; Rest[ Transpose[ NestList[ nxt,{1,2},110]][[2]]] (* _Harvey P. Dale_, May 30 2016 *)

%o (PARI) a(n)=my(q=nextprime(n+1)); while(!isprime(2*n+2-q),q=nextprime(q+1)); if(q%4<3,q,(q+1)/2) \\ _Charles R Greathouse IV_, Feb 28 2013

%Y Cf. A002372, A222566, A222532.

%K nonn

%O 1,1

%A _Zhi-Wei Sun_, Feb 28 2013