# Golang : Math pow(the power of x^y) example

No programming language will be complete without `the power of`

math function. This tutorial is a simple example on how to use `math.Pow()`

function.

In Math

2^5 = 2x2x2x2x2 =32In Golang

Math.pow(2, 5)

In code :

```
package main
import (
"fmt"
"math"
)
func main() {
result := math.Pow(2, 5)
fmt.Println(" 2 power of 5 is : ", result)
x := 10.5
y := 5
floatResult := math.Pow(x, float64(y)) //type cast int to float64
fmt.Printf(" %.02f power of %d is : %.02f \n", x, y, floatResult)
}
```

2 power of 5 is : 32

10.50 power of 5 is : 127628.16

##### By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.

#### Advertisement

#### Tutorials

+3.2k Golang : Intercept, inject and replay HTTP traffics from web server

+19.3k PHP : Count number of JSON items/objects

+4.3k Golang : Get all countries phone codes

+5.4k Golang : Use regular expression to get all upper case or lower case characters example

+11.3k Golang : Count JSON objects and convert to slice/array

+4.8k Golang : Add build version and other information in executables

+22.3k Golang : Encrypt and decrypt data with AES crypto

+3.7k Golang : Oanda bot with Telegram and RSI example

+3.4k Golang : Struct field tags and what is their purpose?

+20k Golang : Save map/struct to JSON or XML file

+6.5k Golang : Clone with pointer and modify value

+9.9k Golang : Loop each day of the current month example