Python program to find the power of a number using recursion
Given a number N and power P. The task is to write a Python program to find the power of a number using recursion.
Definition: The power of a number can be defined as multiplication of the number repetitively the number of times of its power.
Input: N=2 , P=3 Output: 8 Input: N=5 , P=2 Output: 25
The idea is to calculate power of a number ‘N’ is to multiply that number ‘P’ times i.e In first example N=2 and P=3, we are getting the result by multiplying 2 three times repetitively which gives us output 8.
Below is the implementation:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course