Last active
January 15, 2017 00:09
-
-
Save amstee/b736e5d39dab53f6223e66e0905127ef to your computer and use it in GitHub Desktop.
An answer for the exercise sqrt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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