1.尾递归
double f(double guess){
if (isGoodEnough(guess)) return guess;
else return f(improve(guess));
}
2.优化
double f(double initialGuess){
double guess = initialGuess;
while(!isGoodEnough(guess))
guess = improve(guess)
return guess;
}
1.尾递归
double f(double guess){
if (isGoodEnough(guess)) return guess;
else return f(improve(guess));
}
2.优化
double f(double initialGuess){
double guess = initialGuess;
while(!isGoodEnough(guess))
guess = improve(guess)
return guess;
}