Exercise · Functions · lesson 7 of 8
Exercise: power by recursion
Write a recursive function power(base, exp) that returns base raised to the power exp. Do not use the ** operator.
power(2, 10)→1024power(-2, 3)→-8power(7, 0)→1
Constraints: base is an integer from -10 to 10, zero and negative values included. exp is an integer from 0 to 50; any number to the power 0 is 1, including power(0, 0).
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.