Add all the A tasks

This commit is contained in:
Ingy döt Net 2013-04-10 14:58:50 -07:00
parent 2dd7375f96
commit 051504d65b
1608 changed files with 18584 additions and 0 deletions

View file

@ -0,0 +1,25 @@
/*
Arithmetic-Geometric Mean of 1 & 1/sqrt(2)
Brendan Shaklovitz
5/29/12
*/
public class ArithmeticMean {
public static void agm (double a, double g){
double a1 = a;
double g1 = g;
while (Math.abs(a1-g1) >= Math.pow(10, -14)){
double aTemp = (a1+g1)/2.0;
g1 = Math.sqrt(a1*g1);
a1 = aTemp;
}
System.out.println(a1);
}
public static void main(String[] args){
agm(1,1/Math.sqrt(2));
}
}