OFFSET
1,1
COMMENTS
The terms essentially double at each step. The ratios of successive terms are 2.219512195, 0.2527472527, 2.043478261, 2.127659574, 2.150000000, 1.967441860, 1.924349882, 1.831695332, 1.898725687, 1.932179442, 1.638391225, 1.914081678, 1.916987292, 1.912176134, 1.914217557, 1.913630095, 1.918063177, 1.921124765, 1.925186539, 1.927099934, 1.929679007, 1.932327740, 1.934260814, 1.936260826, 1.938224550, 1.940338983, 1.941933414, 1.703444165, 1.948570058, 1.948081161, 1.948559605, 1.949455124...
MATHEMATICA
nn = 2^20; c[_] := False; a[1] = j = 1; c[1] = True;
Differences@ Monitor[Reap[
Do[p = Prime[n - 1];
If[And[# > 0, ! c[#]], k = #,
If[c[#], k = 0; Sow[n], k = #] &[j + p]] &[j - p];
Set[{c[k], j}, {True, k}], {n, 2, nn}]][[-1, 1]], n] (* Michael De Vlieger, Mar 07 2024 *)
PROG
(Python)
from itertools import count, islice
from sympy import nextprime
def A370951_gen(): # generator of terms
a, aset, p, q = 1, {1}, 2, 0
for c in count(2):
if (b:=a-p) > 0 and b not in aset:
a = b
elif (b:=a+p) not in aset:
a = b
else:
a = 0
if q:
yield c-q
q = c
aset.add(a)
p = nextprime(p)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Mar 07 2024
EXTENSIONS
a(29)-a(33) from Martin Ehrenstein, Mar 07 2024
STATUS
approved