Files
build-web-application-with-…/de/code/src/mymath/sqrt.go
2015-08-06 20:35:55 +02:00

13 lines
340 B
Go

// Example code for Chapter 1.2 from "Build Web Application with Golang"
// Purpose: Shows how to create a simple package called `mymath`
// This package must be imported from another go file to run.
package mymath
func Sqrt(x float64) float64 {
z := 0.0
for i := 0; i < 1000; i++ {
z -= (z*z - x) / (2 * x)
}
return z
}