OFFSET
1,1
COMMENTS
From Robert Israel, Jul 05 2016: (Start)
For n>1, there are the following cases:
If prime(n)+2 and prime(n)+4 are composite, then a(n) = prime(n)+5.
If exactly one of prime(n)+2 and prime(n)+4 is prime, and prime(n)+6 is composite, then a(n) = prime(n) + 6.
Otherwise, a(n) = prime(n) + 7. (End)
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
N:= 1000: # to get all entries <= N
Primes:= select(isprime, [2, seq(i, i=3..N+7, 2)]):
nprimes:= nops(Primes):
A[1]:= 10:
A[2]:= 10:
for i from 3 to nprimes-1 do
p:= Primes[i];
if p + 5 > N then break fi;
if Primes[i+1] > p + 4 then A[i]:= p + 5
elif (i = nprimes-1 or Primes[i+2] <> p+6) and p+6 <= N then A[i]:= p + 6
elif p+7 <= N then A[i]:= p + 7
else break
fi
od:
seq(A[j], j=1..i-1); # Robert Israel, Jul 05 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Jaroslav Krizek, Mar 06 2010
STATUS
approved