Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func Sqrt(x float64) float64 {
- z := 1.0
- for (z*z - x) > 0.0001 || (z*z - x) < 0 {
- z -= (z*z - x) / (2*z)
- fmt.Println(z)
- }
- return z
- }
- func main() {
- fmt.Println(Sqrt(9))
- fmt.Println(math.Sqrt(9))
- }
Add Comment
Please, Sign In to add comment