Here, We will learn about Hypot() function in math package in go.
Function prototype:
func Hypot(x, y float64) float64
Return value:
Hypot() function in math package returns
Sqrt(x*x + y*y)
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no := math. Hypot(1, 2)
fmt.Printf("%.1f\n", no)
no = math. Hypot(2, 10)
fmt.Printf("%.1f\n", no)
no = math. Hypot(-1, -3)
fmt.Printf("%.1f\n", no)
no = math. Hypot(-3, 3)
fmt.Printf("%.1f\n", no)
}
Output:
2.2
10.2
3.2
4.2
To learn more about golang, Please refer given below link:
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/