double reciprocal(double c)
{
static int n = 10;
if (--n)
{
double temp = reciprocal(c);
return temp * (2 - temp * c);
}
return c / 2;
}
这个程序只能求大于0小于2的倒数,因为0<cy0<1,而程序选取y0=1/2,所以0<c<2.
double reciprocal(double c)
{
static int n = 10;
if (--n)
{
double temp = reciprocal(c);
return temp * (2 - temp * c);
}
return c / 2;
}