Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
a(n) is the least prime p such that q-p = n*(r-q) where p,q,r are consecutive primes.
0

%I #13 Dec 10 2022 10:47:29

%S 3,7,23,6397,139,509,84871,1933,1259,43331,1129,4523,933073,2971,6917,

%T 1568771,9973,32261,4131109,25261,78737,12809359,91033,28229,13626257,

%U 35677,117443,37305713,399793,102701,217795247,288583,296843,240485257,173359,1025957,213158279,1053103,370949,1163010181

%N a(n) is the least prime p such that q-p = n*(r-q) where p,q,r are consecutive primes.

%C a(n) = prime(k) for the first k such that A001223(k) = n*A001223(k+1).

%e a(3) = 23 because 23, 29, 31 are consecutive primes with 29-23 = 3*(31-29) and 23 is the first prime that works.

%p V:= Vector(45): count:= 0:

%p q:= 2: r:= 3:

%p while count < 45 do

%p p:= q; q:= r; r:= nextprime(r);

%p v:= (q-p)/(r-q);

%p if v::integer and v <= 45 and V[v] = 0 then

%p count:= count+1; V[v]:= p;

%p fi

%p od:

%p convert(V,list);

%o (Python)

%o from sympy import nextprime

%o from itertools import count, islice

%o def agen():

%o p, q, r, n, adict = 2, 3, 5, 1, dict()

%o while True:

%o v, rem = divmod(q-p, r-q)

%o if rem == 0 and v not in adict: adict[v] = p

%o while n in adict: yield adict[n]; n += 1

%o p, q, r = q, r, nextprime(r)

%o print(list(islice(agen(), 21))) # _Michael S. Branicky_, Dec 07 2022

%Y Cf. A001223, A179256, A181994.

%K nonn

%O 1,1

%A _Robert Israel_ and _Juri-Stepan Gerasimov_, Dec 07 2022