fork(1) download
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "math"
  6. )
  7.  
  8. func Sqrt(x float64) float64 {
  9. z := float64(1)
  10.  
  11. for v := z - (math.Pow(z, 2)-x)/2/z; math.Abs(v-z) > 0.1; {
  12. z := v
  13. v := z - (math.Pow(z, 2)-x)/2/z
  14. }
  15.  
  16. return z
  17. }
  18.  
  19. func main() {
  20. fmt.Println(Sqrt(2))
  21. }
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
# command-line-arguments
./prog.go:13: v declared and not used
stdout
Standard output is empty