diff --git a/Others/GuassLengendre.java b/Others/GuassLengendre.java new file mode 100644 index 00000000..289516ae --- /dev/null +++ b/Others/GuassLengendre.java @@ -0,0 +1,44 @@ +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