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 #29 Dec 08 2024 17:19:17
%S 97,907,911,919,929,937,941,947,953,967,971,977,983,991,997,9001,9007,
%T 9011,9013,9029,9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,
%U 9137,9151,9157,9161,9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257
%N Primes with first digit 9.
%H Vincenzo Librandi, <a href="/A045715/b045715.txt">Table of n, a(n) for n = 1..1000</a>
%t Flatten[Table[Prime[Range[PrimePi[9 * 10^n] + 1, PrimePi[10^(n + 1)]]], {n, 3}]] (* _Alonso del Arte_, Jul 19 2014 *)
%o (Magma) [p: p in PrimesUpTo(10^4) | Intseq(p)[#Intseq(p)] eq 9]; // _Bruno Berselli_, Jul 19 2014
%o (Magma) [p: p in PrimesInInterval(9*10^n,10^(n+1)), n in [0..3]]; // _Bruno Berselli_, Aug 08 2014
%o (Python)
%o from itertools import chain, count, islice
%o def A045715_gen(): # generator of terms
%o return chain.from_iterable(primerange(9*(m:=10**l),10*m) for l in count(0))
%o A045715_list = list(islice(A045715_gen(),40)) # _Chai Wah Wu_, Dec 08 2024
%o (Python)
%o from sympy import primepi
%o def A045715(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(9*(m:=10**(l:=len(str(x))-1))-1,x))-primepi(min(10*m-1,x))+sum(primepi(9*(m:=10**i)-1)-primepi(10*m-1) for i in range(l))
%o return bisection(f,n,n) # _Chai Wah Wu_, Dec 08 2024
%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.
%Y Column k=9 of A262369.
%K nonn,base,easy
%O 1,1
%A _Felice Russo_
%E More terms from _Erich Friedman_.