HW4.25

时间:2022-09-07 14:30:58

HW4.25

 public class Solution
 {
     public static void main(String[] args)
     {
         double sum;

         for(int i = 10000; i <= 100000; i += 10000)
         {
             sum = 0;
             for(int j = 1; j <= i; j++)
                 sum += 4 * (1.0 / (2 * j - 1) - 1.0 / (2 * j + 1));
             System.out.println("i = " + i + ", π = " + sum);
         }
     }
 }

相关文章