Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #25 Dec 08 2024 17:18:35
%S 5,53,59,503,509,521,523,541,547,557,563,569,571,577,587,593,599,5003,
%T 5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,
%U 5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261
%N Primes with first digit 5.
%C Subsequence of A000040.
%H Vincenzo Librandi, <a href="/A045711/b045711.txt">Table of n, a(n) for n = 1..5000</a>
%t Select[Table[Prime[n], {n, 5300}], First[IntegerDigits[#]]==5 &] (* _Vincenzo Librandi_, Aug 08 2014 *)
%o (Magma) [p: p in PrimesUpTo(5300) | Intseq(p)[#Intseq(p)] eq 5]; // _Vincenzo Librandi_, Aug 08 2014
%o (Python)
%o from itertools import chain, count, islice
%o from sympy import primerange
%o def A045711_gen(): # generator of terms
%o return chain.from_iterable(primerange(5*(m:=10**l),6*m) for l in count(0))
%o A045711_list = list(islice(A045711_gen(),40)) # _Chai Wah Wu_, Dec 08 2024
%o (Python)
%o from sympy import primepi
%o def A045711(n):
%o def bisection(f,kmin=0,kmax=1):
%o while f(kmax) > kmax: kmax <<= 1
%o while kmax-kmin > 1:
%o kmid = kmax+kmin>>1
%o if f(kmid) <= kmid:
%o kmax = kmid
%o else:
%o kmin = kmid
%o return kmax
%o def f(x): return n+x+primepi(min(5*(m:=10**(l:=len(str(x))-1))-1,x))-primepi(min(6*m-1,x))+sum(primepi(5*(m:=10**i)-1)-primepi(6*m-1) for i in range(l))
%o return bisection(f,n,n) # _Chai Wah Wu_, Dec 08 2024
%Y Column k=5 of A262369.
%Y For primes with initial digit d (1 <= d <= 9) see A045707, A045708, A045709, A045710, A045711, A045712, A045713, A045714, A045715; A073517, A073516, A073515, A073514, A073513, A073512, A073511, A073510, A073509.
%K nonn,base,easy
%O 1,1
%A _Felice Russo_
%E More terms from _Erich Friedman_.
%E Leading 5 added by _Jaroslav Krizek_, Apr 29 2010