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”).

Rearrangement of primes such that the sum of two consecutive terms is a square.
4

%I #13 Dec 09 2019 03:13:08

%S 2,7,29,71,73,251,5,11,53,47,17,19,557,227,97,3,13,23,41,59,137,263,

%T 61,83,113,31,293,107,37,863,433,467,109,1187,257,67,509,167,89,311,

%U 173,151,1613,503,281,43,101,223,353,131,193,383,401,499,797,103,1193,571

%N Rearrangement of primes such that the sum of two consecutive terms is a square.

%C Bunyakovsky's conjecture implies that a(n) always exists. - _Robert Israel_, Dec 08 2019

%H Robert Israel, <a href="/A083016/b083016.txt">Table of n, a(n) for n = 1..10000</a>

%p N:= 10^4: # to get all terms before the first term > N

%p Primes:= select(isprime, [seq(i,i=3..N,2)]):

%p A[1]:= 2:

%p for n from 2 do

%p found:= false;

%p for k from 1 to nops(Primes) do

%p if issqr(A[n-1]+Primes[k]) then

%p A[n]:= Primes[k];

%p Primes:= subsop(k=NULL,Primes);

%p found:= true;

%p break

%p fi

%p od;

%p if not found then break fi

%p od:

%p seq(A[i],i=1..n-1); # _Robert Israel_, Dec 08 2019

%o (PARI) { PS(a)= v=vector(a); v[1]=1; k=prime(1); print1(k","); while(1,t=0; for(s=1,a,r=prime(s); if(v[s]==0 && issquare(k+r),t=r; v[s]=1; break)); if(t==0,break); print1(r","); k=r) }

%K nonn

%O 1,1

%A _Jason Earls_, May 28 2003