In this post I'm going to write my own power function in python which will perform like pow(x,n) in Py3
# Power function using recursion ->
def power(num,exp):
if exp==1:
return num
return num*power(num,exp-1)
print(f"The value is {power(5,3)})
output -
The value is 125
Top comments (0)