Skip to content

Instantly share code, notes, and snippets.

@kakkun61
Last active December 19, 2015 15:09
Show Gist options
  • Save kakkun61/5974638 to your computer and use it in GitHub Desktop.
Save kakkun61/5974638 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0;
for i := 0; i < 10; i++ {
z = z - (math.Pow(z, 2) - x) / (2 * z)
}
return z
}
func main() {
fmt.Println(Sqrt(2))
fmt.Println(math.Sqrt(2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment