%I #28 Dec 05 2020 04:13:27
%S 2,2,5,7,1,1,1,1,2,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,7,
%T 8,8,8,8,9,9,9,9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
%U 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
%N Initial digit of the (10^n)-th prime.
%C The algorithm in the PARI program approximates the (10^n)-th prime to an accuracy of roughly n/2 + 1 digits. As a result, we are almost certain to get the initial digit correctly. It remains to prove this. Since the Riemann approximation of pi(x) is used as a boundary in the exponential bisection routine, it would seem that a proof is possible in view of the fact that bisection almost always guarantees convergence. "Almost" is an appropriate term here, as will be demonstrated when we let the initial parameter r2 = 1. For example, we can toggle print(dx) to check the convergence. For primex(1e116), we get 9.999999999999999999999999970 E115.
%H Robert G. Wilson v, <a href="/A120843/b120843.txt">Table of n, a(n) for n = 0..1000</a>
%F a(n) = most significant digit of A006988(n). - _Robert G. Wilson v_, Jan 17 2017
%F a(n) = A000030(A006988(n)). - _Michel Marcus_, Jan 18 2017
%e The (10^3)-th prime is 7919, so a(3)=7.
%t f[n_] := RealDigits[ n (Log[n] + Log[Log[n]] - 1 + (Log[Log[n]] - 2)/Log[n] - (Log[Log[n]]^2 - 6 Log[Log[n]] + 11)/(2 Log[n]^2)), 10, 10][[1, 1]]; f[1] = f[10] = 2; f[100] = 5; Array[ f[10^#] &, 105, 0] (* _Robert G. Wilson v_, Jan 15 2017 *)
%o (PARI) g(n) = print1(2", "); for(x=1, n, y=Vec(Str(primex(10^x))); print1(y[1]", "))
%o primex(n) = /* Efficient Algorithm to accurately approximate the n-th prime */ { local(x, px, r1, r2, r, p10, b, e); b=10; /*Select base*/ p10=log(n)/log(10); /*p10=pow of 10 n is to adjust in b^p10*/ if(Rg(b^p10*log(b^(p10+1)))< b^p10, m=p10+1, m=p10); r1 = 0; r2 = 2.718281828; /*Real kicker. if 1, it fails at 1e117*/ for(x=1, 360, r=(r1+r2)/2; px = Rg(b^p10*log(b^(m+r))); if(px <= b^p10, r1=r, r2=r); r=(r1+r2)/2.; ); (b^p10*log(b^(m+r))+.5); }
%o Rg(x) = /* Gram's Riemann's Approx of Pi(x) */{ local(n=1, L, s=1, r); L=r=log(x); while(s<10^100*r, s=s+r/zeta(n+1)/n; n=n+1; r=r*L/n); (s) }
%Y Cf. A000030, A006988, A077648.
%K base,nonn
%O 0,1
%A _Cino Hilliard_, Aug 18 2006