Skip to content

Instantly share code, notes, and snippets.

@kimitoboku
Created May 3, 2014 07:16
Show Gist options
  • Save kimitoboku/11493153 to your computer and use it in GitHub Desktop.
Save kimitoboku/11493153 to your computer and use it in GitHub Desktop.
A Tour of Go#24
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
var z float64 = 10
for i := 0; i < 10; i++ {
z = z - (z*z-x)/(2*z)
}
return z
}
func main() {
fmt.Println(Sqrt(2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment