public static int IntegerPower(int base, int power, int result)
all you need in Exponential operations are base and exponent, why do you also have the
result in your parameter?
My code when run multiplies and then saves the number. (I.E. 2^2=4, but 2^3= 2*2=4 and 4 would get saved so the last calculation would be 4*4=16).
your solution is wrong
because you mean that
2^3 = 16?
actually
2^3 is
8 not
16
how?
base = 2
exponent = 3
multiply the base by itself 3 times:
base * base * base = answer
2 * 2 * 2 = 8
another example 2^4 = 16 how:
base = 2
exponent = 4
multiply the base by itself 4 times
base * base * base * base = answer
2 * 2 * 2 * 2 = 16
you can use scientific calculator for verification.
The following is the code I believe the problem is in the while loop, as I don't know how to make it so it doesn't save the problem of the first calculation:
the problem is your solution as what I told above:
while(count<power)
{
base*=base;
count++;
}