%I #7 Dec 05 2013 19:55:11
%S 2,9,6,12,8,4,18,14,10,20,24,22,30,32,16,36,44,40,26,28,38,48,34,42,
%T 50,46,60,54,56,52,66,62,78,64,72,68,70,86,76,74,96,84,90,82,80,58,92,
%U 88,104,102,106,98,100,110,112,120,132,108,140,94,116,114,124,126,128,136
%N a(1) = 2; a(n+1) = smallest composite number not in the sequence such that the sum of all the terms is prime.
%e a(3) = 6 not 4 as 2 + 9 + 6 = 17 is prime, while 2+9 +4 = 15 is composite.
%p a[1] := 2:for i from 2 to 120 do j := 2:while(true)do j := j+1: if((not isprime(j)) and (not (j=a[i-1]))) then bo := true: for h from 1 to i-1 do if(a[h]=j) then bo := false end if:end do: if(isprime(sum(a[k],k=1..i-1)+j) and bo=true) then a[i] := j:break:end if:end if:end do:end do:seq(a[k],k=1..120);
%Y Cf. A068631.
%K easy,nonn
%O 0,1
%A _Amarnath Murthy_, Feb 26 2002
%E Corrected and extended by _Sascha Kurz_, Mar 26 2002