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.

A308438 a(n) is the smallest prime p whose decimal expansion begins with n and is such that the next prime is p+2n, or -1 if no such prime exists.

Original entry on oeis.org

11, 223, 31, 401, 547, 619, 773, 8581, 9109, 10223, 1129, 12073, 130553, 14563, 150011, 161471, 17257, 18803, 191189, 20809, 210557, 225383, 237091, 240209, 2509433, 2613397, 277429, 283211, 2901649, 308153, 313409, 3204139, 3300613, 3419063, 3507739, 360091, 3727313, 3806347, 3930061, 4045421, 41018911
Offset: 1

Views

Author

J. M. Bergot and Robert Israel, May 30 2019

Keywords

Examples

			For n = 5, 547 is a prime starting with 5, and the next prime after 547 is 557 = 547 + 2*5.  Since this is the least number with these properties, a(5) = 547.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local d,p,q;
      for d from 0 do
        p:= nextprime(n*10^d-1);
        do
          q:= nextprime(p);
          if q - p = 2*n then return p fi;
          if q >= (n+1)*10^d then break fi;
          p:= q;
        od;
      od;
    end proc:
    map(f, [$1..50]);
  • Python
    from sympy import nextprime
    def A308438(n):
        l, p = 1, nextprime(n)
        while True:
            q = nextprime(p)
            if q-p == 2*n:
                return p
            p = q
            if p >= (n+1)*l:
                l *= 10
                p = nextprime(n*l) # Chai Wah Wu, May 31 2019