Skip to content

Instantly share code, notes, and snippets.

@evrial
Created October 20, 2015 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evrial/2087b3f6eeb29b03bf3e to your computer and use it in GitHub Desktop.
Save evrial/2087b3f6eeb29b03bf3e to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
z := x / 2.0
for i := 0; i < 10; i++ {
z = z - (z*z-x)/(2*z)
}
return z
}
func main() {
fmt.Println(Sqrt(12))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment