OFFSET
1,2
COMMENTS
The terms 9, 15, 21, 25, 27, 33, 35, 39, 45, 49, 51, ... will never appear in the sequence; they form A071904, the "Odd composite numbers".
LINKS
Michael De Vlieger, Annotated log-log scatterplot of a(n), n = 1..10^4, showing records in red, local minima in blue, composite powers of 2 in magenta, and fixed points in gold.
EXAMPLE
The earliest pairs with their prime sum: (1, 2) = 3, (3, 4) = 7, (5, 6) = 11, (7, 10) = 17, (8, 11) = 19, (12, 17) = 29, (13, 16) = 29, (14, 23) = 37, etc.
MATHEMATICA
nn = 120; c[_] = 0; a[1] = c[1] = 1; u = 2; Do[k = u; If[EvenQ[i], While[Nand[c[k] == 0, PrimeQ[# + k]] &[a[i - 1]], k++]]; Set[{a[i], c[k]}, {k, i}]; If[k == u, While[Or[c[u] > 0, And[OddQ[u], CompositeQ[u]]], u++]], {i, 2, nn}]; Array[a, nn] (* Michael De Vlieger, May 24 2022 *)
PROG
(Python)
from sympy import isprime
from itertools import islice
def agen(): # generator of terms
i, j, v, aset = 1, 2, 3, set()
while True:
aset.update((i, j)); yield from (i, j)
i = v
while i in aset or (i%2 == 1 and not isprime(i)):
i += 1
j, p = v, isprime(i)
while j==i or j in aset or not (isprime(i+j) and (p or isprime(j))):
j += 1
while v in aset: v += 1
print(list(islice(agen(), 74))) # Michael S. Branicky, Jun 24 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and Carole Dubois, May 24 2022
STATUS
approved