16 lines
245 B
Go
16 lines
245 B
Go
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
|
|
}
|
|
}
|
|
}
|