Created
May 31, 2013 04:11
-
-
Save michiel/5682903 to your computer and use it in GitHub Desktop.
Newton's sqrt approximation method in Go
This file contains 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) (y float64) { | |
y = 1 | |
for i := 0; i < 10; i++ { | |
y = y - ((y*y - x) / (2*y)) | |
} | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment