hi there, can someone help me how to write a recursive function that takes the number to the power. Thus, if the number is 2 and the power is 4, the function will return 16.

I'm looking forward for anyone to help me with this my problem.

I try to solve it to myself but i can't find the right code for this.

I don't know how to explain it, so I would rather show how it process: Let say power = 4

Number to return = number * byThePower(number, 3)

byThePower(number, 3) = number * byThePower(number, 2)

byThePower(number, 2) = number * byThePower(number, 1)

byThePower(number, 1) = number * byThePower(number, 0)

Because of byThePower(number, 0) will probally return 1 so that.

byThePower(number, 1) = number * 1 = number

byThePower(number, 2) = number * byThePower(number, 1) = number * number

byThePower(number, 3) = number * byThePower(number, 2) = number * number * number

Number to return = number * byThePower(number, 3) = number * number * number * number

Moreover, I prefer if (power >= 1) than if (power != 0) since it is safer. If you use if (power != 0) and the power is a negative number, then it leads to infinitive loop.

I don't know how to explain it, so I would rather show how it process: Let say power = 4

Number to return = number * byThePower(number, 3)

byThePower(number, 3) = number * byThePower(number, 2)

byThePower(number, 2) = number * byThePower(number, 1)

byThePower(number, 1) = number * byThePower(number, 0)

Because of byThePower(number, 0) will probally return 1 so that.

byThePower(number, 1) = number * 1 = number

byThePower(number, 2) = number * byThePower(number, 1) = number * number

byThePower(number, 3) = number * byThePower(number, 2) = number * number * number

Number to return = number * byThePower(number, 3) = number * number * number * number

Moreover, I prefer if (power >= 1) than if (power != 0) since it is safer. If you use if (power != 0) and the power is a negative number, then it leads to infinitive loop.

Now i understand, thanks for helping me and giving information...
thanks for everything....

Hello guys, hope you all fine,,
I have a problem when coding using python and opencv.
My project is to track the ball in model soccer pitch using raspberry pi ...