Skip to content

Instantly share code, notes, and snippets.

@EteimZ
Last active October 17, 2022 12:44
Show Gist options
  • Select an option

  • Save EteimZ/3c9dd3c6465b5591739637aedb6abd46 to your computer and use it in GitHub Desktop.

Select an option

Save EteimZ/3c9dd3c6465b5591739637aedb6abd46 to your computer and use it in GitHub Desktop.
Go snippets
package main
import (
"fmt"
)
/*
GO program to calculate
the square root of a number
*/
func Sqrt(x float64) float64 {
z := 1.0
for i := 0; i < 10; i++ {
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