diff --git a/exercise-loops-and-functions.go b/exercise-loops-and-functions.go index 6b8995a..32885c4 100644 --- a/exercise-loops-and-functions.go +++ b/exercise-loops-and-functions.go @@ -7,7 +7,7 @@ import ( func Sqrt(x float64) float64 { var p float64 - for z := 1.0; z != p; z -= (z * z - x) / (2 * z) { + for z := 1.0; z != p && math.Abs(z - p) > 0.000000000000001; z -= (z * z - x) / (2 * z) { p = z } return p