%I #4 Mar 30 2012 17:27:41
%S 1,3,6,19,14,7,18,37,20,43,14,51,82,41,84,37,96,149,88,155,226,299,
%T 220,137,48,155,58,159,56,165,52,179,310,173,34,183,32,189,26,193,20,
%U 199,18,217,26,219,416,205,428,201,434,205,444,193,434,177,446,183,454,731
%N a(0) = 1; a(n+1) is the smallest positive number (of at most two) such that abs(a(n) - a(n+1)) is the smallest prime not occurring earlier as difference of successive terms and a(n) + a(n+1) is composite.
%C There are numbers which occur more than once, e.g. a(6) = a(42) = 18, a(8) = a(40) = 20.
%C Problem: Does every positive integer eventually occur?
%e a(4) = 14; the smallest prime not occurring earlier as difference of successive terms is 7; there are two numbers x such that abs(14 - x) = 7 and 14 + x is composite, namely x = 7 and x = 21. The smaller of these numbers is 7, so a(5) = 7.
%e a(11) = 51; the smallest prime not occurring earlier as difference of successive terms is 31; there are two numbers x such that abs(51 - x) = 31, namely x = 20 and x = 82 and 51 + 20 = 71 is not composite while 51 + 82 = 133 is composite;
%e hence a(12) = 82.
%o (PARI) {in(n,v)=local(j,s,b); j=1; s=matsize(v)[2]; b=1; while(b&&j<=s,if(n==v[j],b=0,j++)); !b}
%o {print1(a=1,","); v=[]; for(n=1,60,p=2; t=1; while(t>0,if(in(p,v),p=nextprime(p+1),if(p<a&&!isprime(2*a-p),t=0; b=a-p,if(!isprime(2*a+p),t=0; b=a+p,p=nextprime(p+1))))); v=concat(v,p); print1(a=b,","))}
%Y Cf. A085061, A085402.
%K nonn
%O 0,2
%A _Klaus Brockhaus_, Jun 28 2003