Created
January 23, 2018 16:34
-
-
Save gasolin/7e2b39c9e4bcd57c867cd5f871a92eb0 to your computer and use it in GitHub Desktop.
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
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