Skip to content

Instantly share code, notes, and snippets.

@parasj
Last active August 29, 2015 13:58
Show Gist options
  • Save parasj/10332914 to your computer and use it in GitHub Desktop.
Save parasj/10332914 to your computer and use it in GitHub Desktop.
Learning Go
http://tour.golang.org
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
z := 1.0
delta := 1.0
const delta_lim float64 = .000001
for delta > delta_lim || delta < -1*delta_lim {
delta = z
z = z - (z*z-x)/(2*z)
delta = z - delta
}
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