hanayo/vendor/github.com/felipeweb/gopher-utils/math.go

16 lines
245 B
Go
Raw Normal View History

2019-02-23 13:29:15 +00:00
package gopher_utils
// PowInt is int type of math.Pow function.
func PowInt(x int, y int) int {
if y <= 0 {
return 1
} else {
if y%2 == 0 {
sqrt := PowInt(x, y/2)
return sqrt * sqrt
} else {
return PowInt(x, y-1) * x
}
}
}