Skip to content

Instantly share code, notes, and snippets.

@gasolin
Created January 23, 2018 16:34
Show Gist options
  • Save gasolin/7e2b39c9e4bcd57c867cd5f871a92eb0 to your computer and use it in GitHub Desktop.
Save gasolin/7e2b39c9e4bcd57c867cd5f871a92eb0 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
z := float64(1)
for i := 0; i < 100000; 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