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.

A018800 Smallest prime that begins with n.

This page as a plain text file.
%I A018800 #65 Nov 04 2023 08:46:44
%S A018800 11,2,3,41,5,61,7,83,97,101,11,127,13,149,151,163,17,181,19,2003,211,
%T A018800 223,23,241,251,263,271,281,29,307,31,3203,331,347,353,367,37,383,397,
%U A018800 401,41,421,43,443,457,461,47,487,491,503,5101,521,53,541,557,563,571,587,59
%N A018800 Smallest prime that begins with n.
%C A018800 Conjecture: If a(n) = (n concatenated with k) then k < n. - _Amarnath Murthy_, May 01 2002
%C A018800 a(n) always exists. Proof. Suppose n is L digits long, and consider the numbers between n*10^B and n*10^B+10^C, where B > C are both large compared with L. All such numbers begin with the digits of n. Using the upper and lower bounds on pi(x) from Theorem 1 of Rosser and Schoenfeld, it follows that for sufficiently large B and C, at least one of these numbers is a prime. QED - _N. J. A. Sloane_, Nov 14 2014
%H A018800 T. D. Noe, <a href="/A018800/b018800.txt">Table of n, a(n) for n = 1..1000</a> (first 100 terms from Paolo P. Lava)
%H A018800 J. Barkley Rosser and Lowell Schoenfeld, <a href="http://projecteuclid.org/euclid.ijm/1255631807">Approximate formulas for some functions of prime numbers</a>, Illinois J. Math. 6 (1962), pp. 64-94.
%H A018800 <a href="/index/Pri#piden">Index entries for primes involving decimal expansion of n</a>
%F A018800 a(n) = prime(A085608(n)). - _Michel Marcus_, Oct 19 2013
%p A018800 f:= proc(n) local x0, d,r,y;
%p A018800    if isprime(n) then return(n) fi;
%p A018800    for d from 1 do
%p A018800      x0:= n*10^d;
%p A018800      for r from 1 to 10^d-1 by 2 do
%p A018800        if isprime(x0+r) then
%p A018800           return(x0+r)
%p A018800        fi
%p A018800      od
%p A018800    od
%p A018800 end proc:
%p A018800 seq(f(n),n=1..100); # _Robert Israel_, Dec 23 2014
%t A018800 Table[Function[d, FromDigits@ SelectFirst[ IntegerDigits@ Prime@ Range[10^4], Length@ # >= Length@ d && Take[#, Length@ d] == d &]][ IntegerDigits@ n], {n, 59}] (* _Michael De Vlieger_, May 24 2016, Version 10 *)
%o A018800 (Haskell)
%o A018800 import Data.List (isPrefixOf, find); import Data.Maybe (fromJust)
%o A018800 a018800 n = read $ fromJust $
%o A018800             find (show n `isPrefixOf`) $ map show a000040_list :: Int
%o A018800 -- _Reinhard Zumkeller_, Jul 01 2015
%o A018800 (PARI) a(n{,base=10}) = for (l=0, oo, forprime (p=n*base^l, (n+1)*base^l-1, return (p))) \\ _Rémy Sigrist_, Jun 11 2017
%o A018800 (Python)
%o A018800 from sympy import isprime
%o A018800 def a(n):
%o A018800     if isprime(n): return n
%o A018800     pow10 = 10
%o A018800     while True:
%o A018800         t, maxt = n * pow10 + 1, (n+1) * pow10
%o A018800         while t < maxt:
%o A018800             if isprime(t): return t
%o A018800             t += 2
%o A018800         pow10 *= 10
%o A018800 print([a(n) for n in range(1, 60)]) # _Michael S. Branicky_, Nov 02 2021
%Y A018800 Cf. A030665, A068164, A068695, A062584, A088781, A085608.
%Y A018800 A164022 is the base-2 analog.
%Y A018800 Cf. also A258337.
%Y A018800 Row n=1 of A262369.
%K A018800 nonn,base
%O A018800 1,1
%A A018800 _David W. Wilson_