import java.lang.Math; /* * author: @AKS1996 * Guass Legendre Algorithm * ref https://en.wikipedia.org/wiki/Gauss–Legendre_algorithm * */ public class GuassLegendre { public static void main(String[] args) { for(int i=1;i<=3;++i) System.out.println(pi(i)); } static double pi(int l){ /* * l: No of loops to run */ double a = 1,b=Math.pow(2,-0.5),t=0.25,p=1; for(int i=0;i