Power

Report a typo

Let's create an anonymous function, that is engaged in raising a number to a power. A function will depend on two variables: the base and the exponent. Both numbers are int. A function returns a result of the expression: baseexponent.

By the input, you will get two numbers. You need to output a number — the return of an anonymous function.

Sample Input 1:

2 5

Sample Output 1:

32
Write a program in Go
package main

import (
"fmt"
)

func main() {
var base, exponent int
fmt.Scan(&base, &exponent)

pow := ?(n, e int) ? {
result := 1
for e > 0 {
result *= n
e--
}
return result
}

fmt.Println(?)
}
___

Create a free account to access the full topic