Given a non-empty list L of integers greater than 1, we define d(L) as the smallest positive integer such that n + d(L) is composite for each n in L.
We define the sequence an as:
- a0 = 2
- ai+1 is the smallest integer greater than ai such that d(a0, ..., ai, ai+1) > d(a0, ..., ai)
Your task
You may either:
- Take an integer N and return the N-th term of the sequence (0-indexed or 1-indexed)
- Take an integer N and return the first N terms of the sequence
- Take no input and print the sequence forever
This is code-golf, so the shortest answer in bytes wins!
It's OK if your code is getting slow as N gets larger, but it should at least find the 20 first terms in less than 2 minutes.
First terms
- a0 = 2 and d(2) = 2 (we need to add 2 so that 2+2 is composite)
- a1 = 3 because d(2, 3) = 6 (we need to add 6 so that 2+6 and 3+6 are composite)
- a2 = 5 because d(2, 3, 5) = 7 (we need to add 7 so that 2+7, 3+7 and 5+7 are all composite), whereas d(2, 3, 4) is still equal to 6
- etc.
Below are the 100 first terms of the sequence (unknown on OEIS at the time of posting).
2, 3, 5, 6, 10, 15, 17, 19, 22, 24,
30, 34, 35, 39, 41, 47, 51, 54, 56, 57,
70, 79, 80, 82, 92, 98, 100, 103, 106, 111,
113, 116, 135, 151, 158, 162, 165, 179, 183, 186,
191, 192, 200, 210, 217, 223, 226, 228, 235, 240,
243, 260, 266, 274, 277, 284, 285, 289, 298, 307,
309, 317, 318, 329, 341, 349, 356, 361, 374, 377,
378, 382, 386, 394, 397, 405, 409, 414, 417, 425,
443, 454, 473, 492, 494, 502, 512, 514, 519, 527,
528, 560, 572, 577, 579, 598, 605, 621, 632, 642