login
First differences of A112877 (zero terms in Cald's sequence A006509).
3

%I #22 Mar 24 2024 10:48:46

%S 82,182,46,94,200,430,846,1628,2982,5662,10940,17924,34308,65768,

%T 125760,240732,460672,883598,1697502,3268008,6297778,12152690,

%U 23482980,45422208,87949242,170465380,330760622,642315104,1094147916,2132023868,4153355532,8093060816,15777058876

%N First differences of A112877 (zero terms in Cald's sequence A006509).

%C 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...

%t nn = 2^20; c[_] := False; a[1] = j = 1; c[1] = True;

%t Differences@ Monitor[Reap[

%t Do[p = Prime[n - 1];

%t If[And[# > 0, ! c[#]], k = #,

%t If[c[#], k = 0; Sow[n], k = #] &[j + p]] &[j - p];

%t Set[{c[k], j}, {True, k}], {n, 2, nn}]][[-1, 1]], n] (* _Michael De Vlieger_, Mar 07 2024 *)

%o (Python)

%o from itertools import count, islice

%o from sympy import nextprime

%o def A370951_gen(): # generator of terms

%o a, aset, p, q = 1, {1}, 2, 0

%o for c in count(2):

%o if (b:=a-p) > 0 and b not in aset:

%o a = b

%o elif (b:=a+p) not in aset:

%o a = b

%o else:

%o a = 0

%o if q:

%o yield c-q

%o q = c

%o aset.add(a)

%o p = nextprime(p)

%o A370951_list = list(islice(A370951_gen(),10)) # _Chai Wah Wu_, Mar 07 2024

%Y Cf. A006509, A112877.

%K nonn

%O 1,1

%A _N. J. A. Sloane_, Mar 07 2024

%E a(29)-a(33) from _Martin Ehrenstein_, Mar 07 2024