The question I am having problems with is the following:

Write a method to compute the following series:

m(i) = 4(1 - 1/3 + 1/5 -1/7 + 1/9 - 1/11 + ... + 1/(2i-1) - 1/(2i+1)

here is the code I have put together so far:

Code:

public class series {
public static double m(int i){
double num = 0;
for (i = i;i>0;i--){ //infinite times starting at i
num += 4*((1/(2*((double)i)-1))-(1/(2*((double)i)+1)));
}
return num;
}
public static void main(String args[]){
System.out.println("i m(i)");
for (int i=10;i<=100;i=i+10)
System.out.println(i+" "+(m(i)));
}
}

for some reason it is not displaying the correct results what am I missing?

The expected print out is :

i m(i)

10 3.04184

20 3.09162

etc but mine is starting at 3.809