← Recursion

Power

easy

Compute base raised to exponent recursively – no loop. exponent is always 0 or greater.

This is the lesson’s factorial pattern with the multiplication changed: the base case is exponent == 0 (raising anything to the power 0 is 1), and the recursive case multiplies base by the result of the same problem with exponent one smaller. Trace power(2, 3) by hand, the same way the lesson traced factorial(5), before trusting your code.

Your solution

"Run" uses the sample stdin ("2 10"). "Submit" checks your code against all 4 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution