Skip to content

Instantly share code, notes, and snippets.

@ta1kt0me
Created January 22, 2017 07:03
Show Gist options
  • Select an option

  • Save ta1kt0me/12e5cc93ba4d367f51a8349a93ab82bd to your computer and use it in GitHub Desktop.

Select an option

Save ta1kt0me/12e5cc93ba4d367f51a8349a93ab82bd to your computer and use it in GitHub Desktop.
Exercise: Loops and Functions
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 9.0
for i := 0; i < 10; i++ {
z = z - ((z*z - x) / (2 * z))
}
return z
}
func main() {
fmt.Println(Sqrt(3))
fmt.Println(math.Sqrt(3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment