添加1.2节的代码
This commit is contained in:
11
src/1.2/sqrt.go
Normal file
11
src/1.2/sqrt.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// 章节 1.2
|
||||
// $GOPATH/src/mymath/sqrt.go
|
||||
package mymath
|
||||
|
||||
func Sqrt(x float64) float64 {
|
||||
z := 0.0
|
||||
for i := 0; i < 1000; i++ {
|
||||
z -= (z*z - x) / (2 * x)
|
||||
}
|
||||
return z
|
||||
}
|
||||
Reference in New Issue
Block a user