Skip to content

Instantly share code, notes, and snippets.

@mistermocha
Created October 29, 2014 08:07
Show Gist options
  • Save mistermocha/c4e62bcbeb7131641013 to your computer and use it in GitHub Desktop.
Save mistermocha/c4e62bcbeb7131641013 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func sqrt(x float64) float64 {
y := 0.0
z := 1.0
for y == z {
y = z
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