login
A352952
a(1) = 3; a(2) = 5; a(n+1) = a(n) + b(n), where b(n) = max {a(n-1)+-1, a(n-2)+-1, a(n-3)+-1, ..., a(1)+-1} such that a(n) + b(n) is a prime.
1
3, 5, 7, 13, 19, 31, 43, 73, 103, 109, 211, 313, 523, 733, 751, 1483, 1693, 1801, 2551, 4243, 6793, 9343, 10093, 10303, 12853, 14653, 17203, 19753, 22303, 24103, 25903, 26113, 28663, 28771, 54673, 83443, 112213, 140983, 169753, 171553, 200323, 229093, 257863
OFFSET
1,1
COMMENTS
This sequence is finite and has 111 terms, which are given in the b-file.
a(n) == 1 (mod 6) if n > 2. For n = 3 or > 4, b(n) = a(n-i) - 1, where 1 < b < n.
EXAMPLE
For n = 6, the first 6 terms are [3, 5, 7, 13, 19, 31] and, in the list [19+-1, 13+-1, 7+-1, 5+-1, 3+-1], 13-1 is the largest number that gives a prime when added to a(6). Thus, b(6) = 13 - 1 = 12 and b(7) = a(6) + b(6) = 43.
PROG
(Python)
from sympy import isprime; L = [3, 5]
while 1:
for j in range(2, len(L)+1):
s = L[-1] + L[-j]
if isprime(s+1): L.append(s+1); break
elif isprime(s-1): L.append(s-1); break
else: break
print(*L, sep = ', ')
CROSSREFS
Cf. A337347.
Sequence in context: A206023 A067829 A084696 * A354219 A330222 A154700
KEYWORD
fini,nonn,full
AUTHOR
Ya-Ping Lu, Apr 10 2022
STATUS
approved