OFFSET

0,2

COMMENTS

There are numbers which occur more than once, e.g. a(6) = a(42) = 18, a(8) = a(40) = 20.

Problem: Does every positive integer eventually occur?

EXAMPLE

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.

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;

hence a(12) = 82.

PROG

(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}

{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, ", "))}

CROSSREFS

KEYWORD

nonn

AUTHOR

Klaus Brockhaus, Jun 28 2003

STATUS

approved