2014蓝桥杯-B-省赛-五-圆周率

【答案】:4 / (x - 1))

public class TEST {
    
    

   public static void main(String[] args) {
    
    
      double x = 111;
      for (int n = 10000; n >= 0; n--) {
    
    
         int   i = 2 * n + 1;  //把i变为奇数
         x = 2 + (i * i / x);
      }
      // x=2+1/x'
      System.out.println(String.format("%.4f", 4 / (x - 1)));

   }
}

猜你喜欢

转载自blog.csdn.net/qq_45783660/article/details/113282608