I need to make a recursive function that returns a number to a entered power.
Such as 3 to the 3rd power is 27.
Here's my code so far. But I don't know what to put for the return that would make it recursive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
int PowerFunction(int number, int power); //prototype function
int main()
{
int number, power, result;
std::cout << "Enter number and power\n";
std::cin >> number >> power;
result = PowerFunction(number, power);
std::cout << "Result: \n" << result;
}
int PowerFunction(int number, int power) //defined function
{
return (what to put here?)
}
Do you know what a recursive function is?
Then how would you split up the term 3³ so it still contains a power, but gradually becomes simpler?
Yeah, and that's what you're supposed to put in there.