login
Rearrangement of primes so that sum of the absolute value of the successive differences is also a prime.
3

%I #9 Sep 17 2016 00:21:07

%S 2,5,3,11,7,13,19,17,23,29,47,37,67,31,43,41,53,71,59,89,61,73,79,103,

%T 83,101,107,97,109,139,127,157,131,137,113,149,167,151,163,181,193,

%U 173,197,179,191,227,251,211,277,229,271,223,307,239,263,199,241,283,257

%N Rearrangement of primes so that sum of the absolute value of the successive differences is also a prime.

%C The smallest previously unused prime consistent with the definition is used at each step. - _Franklin T. Adams-Watters_, Oct 09 2006

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

%e 5-2 = 3 is prime, (5-2)+ (5-3) = 5 is a prime,(5-2)+(5-3)+(11-3) = 13 is a prime.

%p N:= 10000: # to use primes up to N

%p A[1]:= 2:

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

%p s:= 0:

%p for n from 2 do

%p for i from 1 to nops(P) do

%p if isprime(s + abs(P[i]-A[n-1])) then

%p s:= s+abs(P[i]-A[n-1]);

%p A[n]:= P[i];

%p P:= subsop(i=NULL,P);

%p break

%p fi

%p od;

%p if not assigned(A[n]) then break fi;

%p od:

%p seq(A[i],i=1..n-1); # _Robert Israel_, Sep 16 2016

%Y Cf. A094743, A094745.

%K nonn

%O 1,1

%A _Amarnath Murthy_, May 24 2004

%E Corrected and extended by _Franklin T. Adams-Watters_, Oct 09 2006