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.

A358743 First of three consecutive primes p,q,r such that p+q-r is prime.

This page as a plain text file.
%I A358743 #15 Nov 29 2022 13:28:53
%S A358743 7,11,13,17,19,29,41,43,47,59,79,101,103,107,113,137,139,163,181,193,
%T A358743 227,229,239,257,269,281,283,311,317,359,379,397,419,421,439,461,487,
%U A358743 491,503,521,547,569,577,599,647,659,683,691,701,709,761,811,823,857,863,881,883,887,919,983,1019
%N A358743 First of three consecutive primes p,q,r such that p+q-r is prime.
%C A358743 p+q-r is near (and less than) p and odd (for p > 2), so heuristically we would expect it to be prime about 2/log p of the time, yielding around 2x/log^2 x terms up to x. (A more careful analysis of small primes could yield a slightly different leading constant.) - _Charles R Greathouse IV_, Nov 29 2022
%H A358743 Robert Israel, <a href="/A358743/b358743.txt">Table of n, a(n) for n = 1..10000</a>
%e A358743 a(3) = 13 is a prime because 13, 17, 19 are three consecutive primes with 13 + 17 - 19 = 11 prime.
%p A358743 R:= NULL: count:= 0: q:= 2: r:= 3:
%p A358743 while count < 100 do
%p A358743   p:= q; q:= r; r:=nextprime(r);
%p A358743   if isprime(p+q-r) then count:= count+1; R1:= R1,p fi;
%p A358743 od:
%p A358743 R;
%t A358743 Select[Partition[Prime[Range[180]], 3, 1], PrimeQ[#[[1]] + #[[2]] - #[[3]]] &][[;; , 1]] (* _Amiram Eldar_, Nov 29 2022 *)
%o A358743 (Python)
%o A358743 from itertools import islice
%o A358743 from sympy import isprime, nextprime
%o A358743 def agen():
%o A358743     p, q, r = 2, 3, 5
%o A358743     while True:
%o A358743         if isprime(p+q-r): yield p
%o A358743         p, q, r = q, r, nextprime(r)
%o A358743 print(list(islice(agen(), 61))) # _Michael S. Branicky_, Nov 29 2022
%o A358743 (PARI) list(lim)=my(v=List(),p=7,q=11); forprime(r=13,nextprime(nextprime(lim\1+1)+1), if(isprime(p+q-r), listput(v,p)); p=q; q=r); Vec(v) \\ _Charles R Greathouse IV_, Nov 29 2022
%Y A358743 A136720 is a subsequence.
%Y A358743 Cf. A255581, A358742, A358744.
%K A358743 nonn
%O A358743 1,1
%A A358743 _J. M. Bergot_ and _Robert Israel_, Nov 29 2022