Post what you have tried.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>3^3 = 27.
that's the wrong answer, so you program will never get it (unless the program is wrong) :)
you over-complicated your program -- the solution is much simpler
int byThePower(int number, int power)
{
if(power >1)
number = number * byThePower(number,power-1);
return number;
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I would write it like this: (this code works only when the power is a positive number)
You are right -- the solution I posted doesn't work for power of 0.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>3^3 = 27.
that's the wrong answer, so you program will never get it (unless the program is wrong)
Wuh?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439