%I #46 Jul 14 2019 13:34:55
%S 1,3,4,5,8,47,49,95,247,251,253,742,4268,4270,4288,11445,30123,30701,
%T 30703,62592,62690,62992,3535871,3535872,3664203,3664204,3664214,
%U 3664220,3665670,3665696,3665842,3665854,3665866,3708907,3708909,3708913,3708929,3708931,3708935,3708957,3708983,3708985,3709017
%N Terms of the Leibniz formula (as Euler product) that generate successively better approximations to Pi.
%H Steven Lubars, <a href="/A261208/b261208.txt">Table of n, a(n) for n = 1..71</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80#Euler_product">Euler Product</a>
%F Pi = 4*b(1)*b(2)*b(3)*... where b(n) is the n-th odd prime (A065091) divided by its nearest multiple of 4.
%F Let c(n) be the n-th term of the expansion such that c(n) = 4*b(1)*...*b(n). The sequence consists of the values n such that c(n) provides a closer approximation of Pi than previous approximations c(1)...c(n-1).
%e Calculating the first 8 terms: c(1)=3, c(2)=3.75, c(3)=3.28125, c(4)=3.0078125, c(5)=3.2584635416, c(6)=3.462117513020833, c(7)=3.289011637369791, c(8)=3.1519694858127165.
%e In the above sequence, terms 1, 3, 4, 5, and 8 provide successively closer approximations of Pi (whereas approximations 2, 6, and 7 do not).
%o (PARI) nearmul(p) = if (p % 4 == 1, p-1, p+1);
%o lista(nn) = {print1(lb = 1, ", "); v = 3; ld = abs(Pi-3); for (n=2, nn, np = prime(n+1); v *= np/nearmul(np); if ((nld=abs(Pi-v)) < ld, print1(n, ", "); ld = nld););} \\ _Michel Marcus_, Aug 14 2015
%o (MUMPS)
%o s Pi=3.141592653589793238,a=3,n=1,d=Pi-a
%o w !,1
%o f i=6:6:1e10 d
%o . s L=i+1**.5\1
%o . f j=i-1:2:i+1 d
%o . . f k=3:2:L q:'(j#k)
%o . . i j#k d
%o . . . s a=a*j/(j#4+j-2),n=n+1
%o . . . i $FN(Pi-a,"-")<d d
%o . . . . s d=$FN(Pi-a,"-")
%o . . . . w !,n ; _Steven Lubars_, Aug 14 2015
%Y Cf. A065091, A076342.
%K nonn
%O 1,2
%A _Steven Lubars_, Aug 11 2015