Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue