A354369 Successive pairs of terms (a, b) such that (a + b) is a prime number and at least one of a and b is a prime number. This is the lexicographically earliest infinite sequence of distinct terms > 0 with this property.
1, 2, 3, 4, 5, 6, 7, 10, 8, 11, 12, 17, 13, 16, 14, 23, 18, 19, 20, 41, 22, 31, 24, 29, 26, 47, 28, 43, 30, 37, 32, 71, 34, 67, 36, 53, 38, 59, 40, 61, 42, 89, 44, 83, 46, 103, 48, 79, 50, 101, 52, 97, 54, 73, 56, 107, 58, 109, 60, 113, 62, 131, 64, 127, 66, 157, 68, 173, 70, 163, 72, 139, 74, 137
Offset: 1
Keywords
Examples
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.
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.
Programs
-
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 *)
-
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
Comments