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.

This page as a plain text file.
%I A308438 #23 Jun 01 2019 11:10:21
%S A308438 11,223,31,401,547,619,773,8581,9109,10223,1129,12073,130553,14563,
%T A308438 150011,161471,17257,18803,191189,20809,210557,225383,237091,240209,
%U A308438 2509433,2613397,277429,283211,2901649,308153,313409,3204139,3300613,3419063,3507739,360091,3727313,3806347,3930061,4045421,41018911
%N 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.
%H A308438 Chai Wah Wu, <a href="/A308438/b308438.txt">Table of n, a(n) for n = 1..100</a>
%e A308438 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.
%p A308438 f:= proc(n) local d,p,q;
%p A308438   for d from 0 do
%p A308438     p:= nextprime(n*10^d-1);
%p A308438     do
%p A308438       q:= nextprime(p);
%p A308438       if q - p = 2*n then return p fi;
%p A308438       if q >= (n+1)*10^d then break fi;
%p A308438       p:= q;
%p A308438     od;
%p A308438   od;
%p A308438 end proc:
%p A308438 map(f, [$1..50]);
%o A308438 (Python)
%o A308438 from sympy import nextprime
%o A308438 def A308438(n):
%o A308438     l, p = 1, nextprime(n)
%o A308438     while True:
%o A308438         q = nextprime(p)
%o A308438         if q-p == 2*n:
%o A308438             return p
%o A308438         p = q
%o A308438         if p >= (n+1)*l:
%o A308438             l *= 10
%o A308438             p = nextprime(n*l) # _Chai Wah Wu_, May 31 2019
%Y A308438 Cf. A018800, A030665.
%K A308438 nonn,base,look
%O A308438 1,1
%A A308438 _J. M. Bergot_ and _Robert Israel_, May 30 2019