我正在尝试解决 Go Tour 的练习#8。
我的解决方案失败并显示错误消息the process to take too long
怎么了 ?
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
guess := 1.0
i := 1
for i < 10 {
guess = guess - (math.Pow(guess, 2)-x)/(2*guess)
}
return guess
}
func main() {
fmt.Println(Sqrt(2))
}