
Implement a function that raises base to the power exp by recursion, with two base cases: an exp of 0 gives 1, and a negative exp gives -1.
power(2, 10)Expected result
1024For your own tracking. Tests grade your code.
power(-2, 5)Expected result
-32power(7, 0)Expected result
1power(3, -1)Expected result
-1Expected files
power.cAllowed functions
None. Write every helper yourself.

v0.40: Create exercises. Challenge the community.
Meet Studio →Implement a function that raises base to the power exp by recursion, with two base cases: an exp of 0 gives 1, and a negative exp gives -1.
power(2, 10)Expected result
1024For your own tracking. Tests grade your code.
power(-2, 5)Expected result
-32power(7, 0)Expected result
1power(3, -1)Expected result
-1Expected files
power.cAllowed functions
None. Write every helper yourself.

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.