%I #52 Dec 08 2024 09:56:07
%S 11,13,17,19,101,103,107,109,113,127,131,137,139,149,151,157,163,167,
%T 173,179,181,191,193,197,199,1009,1013,1019,1021,1031,1033,1039,1049,
%U 1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151
%N Primes with first digit 1.
%C Also primes with all divisors starting with digit 1. Complement of A206288 (nonprime numbers with all divisors starting with digit 1) with respect to A206287 (numbers with all divisors starting with digit 1). - _Jaroslav Krizek_, Mar 04 2012
%C Cohen and Katz show that the set of primes with first digit 1 has no natural density, but has supernatural/Dirichlet density log_{10} (2) ~= 0.3, the primes with first digit 2 have (supernatural) density log_{10} (3/2) ~= 0.176, ... and the primes with first digit 9 have density log_{10} (10/9) ~= 0.046. This would seem to explain the first digit phenomenon. Note that sum_{k = 1}^9 log_{10} (k+1)/k = 1. - Gary McGuire, Dec 22 2004
%C Lower density is 1/9, upper density is 5/9. The Dirichlet density, if it exists, is always between the lower and upper density (as it does and is in this case). - _Charles R Greathouse IV_, Sep 26 2022
%H Vincenzo Librandi, <a href="/A045707/b045707.txt">Table of n, a(n) for n = 1..5000</a>
%H Daniel I. A. Cohen and Talbot M. Katz, <a href="http://dx.doi.org/10.1016/0022-314X(84)90061-1">Prime numbers and the first digit phenomenon</a>, J. Number Theory 18 (1984), 261-268.
%t Select[Table[Prime[n], {n, 500}], First[IntegerDigits[#]] == 1 &]
%t Flatten[Table[Prime[Range[PrimePi[10^n] + 1, PrimePi[2 * 10^n]]], {n, 3}]] (* _Alonso del Arte_, Jul 18 2014 *)
%o (Magma) [p: p in PrimesUpTo(10^4) | IsOne(Intseq(p)[#Intseq(p)])]; // _Bruno Berselli_, Jul 19 2014
%o (PARI) list(lim)=my(v=[]); for(d=1,#digits(lim\=1)-1, v=concat(v,primes([10^d,min(lim,2*10^d-1)]))); v \\ _Charles R Greathouse IV_, Sep 26 2022
%o (Python)
%o from itertools import chain, count, islice
%o from sympy import primerange
%o def A045707_gen(): # generator of terms
%o return chain.from_iterable(primerange(m:=10**l,(m<<1)) for l in count(0))
%o A045707_list = list(islice(A045707_gen(),40)) # _Chai Wah Wu_, Dec 07 2024
%o (Python)
%o from sympy import primepi
%o def A045707(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((m:=10**(l:=len(str(x))-1))-1)-primepi(min((m<<1)-1,x))+sum(primepi((m:=10**i)-1)-primepi((m<<1)-1) for i in range(l))
%o return bisection(f,n,n) # _Chai Wah Wu_, Dec 07 2024
%Y For primes with initial digit d (1 <= d <= 9) see A045707 (1, this sequence), A045708 (2), A045709 (3), A045710 (4), A045711 (5), A045712 (6), A045713 (7), A045714 (8), A045715 (9).
%Y Cf. A073517, A073516, A073515, A073514, A073513, A073512, A073511, A073510, A073509
%Y Column k=1 of A262369.
%K nonn,base,easy
%O 1,1
%A _Felice Russo_
%E More terms from _Erich Friedman_.
%E Cohen-Katz reference from _Victor S. Miller_, Dec 21 2004