Sqrt函数的实现方法

1.二分法 

2.Newton迭代法

public int sqrt(int x) {//newton 
		
			int i = 1;
			while(Math.abs(i*i-x) > 1)//精度控制
			{
				i = (i+x/i)/2;
			}

			return i;
		
	}

通过控制精度得到对应精度的结果。

原文地址:https://www.cnblogs.com/catcoding/p/4779382.html