Skip to content

Instantly share code, notes, and snippets.

@amstee
Last active January 15, 2017 00:09
Show Gist options
  • Save amstee/b736e5d39dab53f6223e66e0905127ef to your computer and use it in GitHub Desktop.
Save amstee/b736e5d39dab53f6223e66e0905127ef to your computer and use it in GitHub Desktop.
An answer for the exercise sqrt
func Sqrt(x float64) (z float64) {
z = 1.0
for i := 0; i < 20; i++ {
z = z - (z * z - x) / (2 * z)
}
return z
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment