Here, We will learn how to get the cube root of number in go. We can get it by using Cbrt() function in math package in go golang.
Function prototype:
func Cbrt(no float64) float64
Return value:
Cbrt() function in math package returns
the cube root of number.
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no := math.Cbrt(10)
fmt.Printf("%0.2f\n", no)
no = math.Cbrt(27)
fmt.Printf("%0.2f\n", no)
no = math.Cbrt(125)
fmt.Printf("%0.2f\n", no)
no = math.Cbrt(0.25)
fmt.Printf("%0.2f\n", no)
}
Output:
2.15
3.00
5.00
0.63
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/