9月9日刷题

Sqrt(x)

http://www.guokr.com/question/461510/ 牛顿开方法

   public int sqrt(int x) {
        float X1 = 1f;
        float Xn = x;
        for (int i = 0; i < 20; ++i) {
            Xn = X1 / 2.f + x / (2 * X1);
            X1 = Xn;
        }
        return (int) X1;
    }
原文地址:https://www.cnblogs.com/fripside/p/4796200.html