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.

A287615 Let r = prime(n). Then a(n) is the smallest prime p such that there is a prime q with p > q > r and p mod q = r.

Original entry on oeis.org

5, 13, 19, 29, 37, 47, 79, 101, 97, 103, 113, 131, 127, 137, 181, 199, 181, 227, 233, 229, 239, 257, 277, 283, 311, 307, 317, 409, 383, 367, 389, 409, 439, 521, 463, 509, 491, 509, 613, 571, 541, 563, 577, 587, 619, 653, 677, 677, 709, 743, 787, 853, 743, 877
Offset: 1

Views

Author

Ophir Spector, May 27 2017

Keywords

Comments

Prime p such that p = k * q + r, r < q < p primes; k even multiples such that p is minimal.

Examples

			a(1) = 5, as r = 2, q = 3, p = 5, is the smallest prime such that 5 = 2 mod 3.
a(9) = 97, as r = 23, q = 37, p = 97.  97 = 2 * 37 + 23 is smaller than 139 = 4 * 29 + 23 (A129919).
		

Crossrefs

Cf. A129919.

Programs

  • Maple
    f:= proc(n) local p,q,r;
      r:= ithprime(n);
      p:= r+1;
      do
       p:= nextprime(p);
       q:= max(numtheory:-factorset(p-r));
       if q > r then return p fi
      od:
    end proc:
    map(f, [$1..100]); # Robert Israel, Jun 05 2017
  • Mathematica
    a[n_] := Module[{p, q, r}, r = Prime[n]; p = r+1; While[True, p = NextPrime[p]; q = Max[FactorInteger[p-r][[All, 1]]]; If[q>r, Return[p]]] ];
    Array[a, 100] (* Jean-François Alcover, Oct 06 2020, after Robert Israel *)
  • PARI
    findfirstTerms(n)=my(t:small=0,a:vec=[]);forprime(r=2,,forprime(p=r+2,,forprime(q=r+2,p-2,if(p%q==r,a=concat(a,[p]);if(t++==n,a[1]-=2;return(a),break(2)))))) \\ R. J. Cano, Jun 06 2017
    
  • PARI
    first(n)=my(v=vector(n),best,k=1); v[1]=5; forprime(r=3,prime(n), best=oo; forprime(q=r+2,, if(q>=best, v[k++]=best; next(2)); forstep(p=r+2*q,best,2*q, if(isprime(p), best=p; break)))); v \\ Charles R Greathouse IV, Jun 07 2017