cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A358974 #13 Dec 10 2022 10:47:29
%S A358974 3,7,23,6397,139,509,84871,1933,1259,43331,1129,4523,933073,2971,6917,
%T A358974 1568771,9973,32261,4131109,25261,78737,12809359,91033,28229,13626257,
%U A358974 35677,117443,37305713,399793,102701,217795247,288583,296843,240485257,173359,1025957,213158279,1053103,370949,1163010181
%N A358974 a(n) is the least prime p such that q-p = n*(r-q) where p,q,r are consecutive primes.
%C A358974 a(n) = prime(k) for the first k such that A001223(k) = n*A001223(k+1).
%e A358974 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 A358974 V:= Vector(45): count:= 0:
%p A358974 q:= 2: r:= 3:
%p A358974 while count < 45 do
%p A358974   p:= q; q:= r; r:= nextprime(r);
%p A358974   v:= (q-p)/(r-q);
%p A358974   if v::integer and v <= 45 and V[v] = 0 then
%p A358974     count:= count+1; V[v]:= p;
%p A358974   fi
%p A358974 od:
%p A358974 convert(V,list);
%o A358974 (Python)
%o A358974 from sympy import nextprime
%o A358974 from itertools import count, islice
%o A358974 def agen():
%o A358974     p, q, r, n, adict = 2, 3, 5, 1, dict()
%o A358974     while True:
%o A358974         v, rem = divmod(q-p, r-q)
%o A358974         if rem == 0 and v not in adict: adict[v] = p
%o A358974         while n in adict: yield adict[n]; n += 1
%o A358974         p, q, r = q, r, nextprime(r)
%o A358974 print(list(islice(agen(), 21))) # _Michael S. Branicky_, Dec 07 2022
%Y A358974 Cf. A001223, A179256, A181994.
%K A358974 nonn
%O A358974 1,1
%A A358974 _Robert Israel_ and _Juri-Stepan Gerasimov_, Dec 07 2022