Let's try a recursive function. Write a subroutine
which computes x to the power n by the following
1. if n is zero return 1.
2. if n is odd return x*power(x,n-1).
3. if n is even return the square of
You may assume than x and n are integers, n>=0.
If n is negative return 0 for an answer.
Put your routine on a file "power.c". Compile
it and test it; then type "ready".
if (power(-1,-1) != 0) return(1);
if (power(-3,2) != 9) return(1);
if (power(2,12) != 4096) return(1);
if (power(3,5) != 243) return(1);
if (power(-5, 5) != -3125) return(1);
if (power(7,3) != 343) return(1);
if (power(7,4) != 2401) return(1);
if (power(3,7) != 2187) return(1);
if (power(2,10) != 1024) return(1);
/* a possible solution */
return(x * power(x, n-1));