title: How to solve this equation using java?
body: <p><strong> = √12 × (1/1x3<sup>0</sup> - 1/3x3<sup>1</sup> +  1/5x3<sup>2</sup> - 1/7x3<sup>3</sup> +........)</strong></p>
  <p>I am trying to solve this equation using java but I do not know how to make subtract when the power is odd.</p>
  <pre><code>public static double calculatePiInnitial(int i){
       double sum = 0;
       for (int n=0; n&lt;=i;n++){
           for(int k = 1; k&lt;=k; k =+ 2) {
               if (n % 2 == 0)
                   sum += 1/k*Math.pow(3, n);
               else
                   sum += -1/k* Math.pow(3, n);
           }
  
  
  
       }
      System.out.println(sum);
      final double SQRT_12 = Math.sqrt(12)  ;
      double Pi =  SQRT_12 * sum;
      return Pi ;
  }
  </code></pre>