using System;
using System.Collections.Generic;
class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param x int整型
* @return int整型
*/
public int mysqrt (int x) {
// write code here
double c=1;
double y;
while(true)
{
y=1.0/2*(c+x/c);
if(Math.Abs(c-y)<0.1)
return (int)y;
c=y;
}
}
}
利用 f(x)=x^2-a 迭代求跟, 选取初始点x_0,做切线迭代



京公网安备 11010502036488号