I am trying to figure out what is wrong with these code I kind of have the idea of what to do take the value of pi and verify if it is even add it or if is odd sustacted, however I am not sure about if I have to update the sum variable? and If if What I have done so far it is correct.


I am trying to find the value of PI with the following serie Π = 4( 1 1/3 + 1/5 1/7 + 1/9 1/11 + - 1/(2i -1) + 1/(2i + 1)

assumeing that i = 1000000


Code:
import java.util.Scanner;
	
   public class Pi{
      public static void main(String[] args)
      {
      
      
      int sum=0;
         for (int i=1 ; i< 1000000; i++)
         {
         
            int value  = 1/(2 * i-1);
         
            if (i%2==0)
            {
            
               sum = sum + value;
            
            }
            else
            {
               sum = sum-value; 
            }
         }
			
			
      }