Answer:
The method in java is as follows:
public static int power(int num, int exp){
if(exp == 0){ return 1; }
if(exp < 0){
throw new IllegalArgumentException("Positive exponents only"); }
else{ return (num*power(num, exp-1)); }
}
Where
base
exponent
Step-by-step explanation:
This defines the method
public static int power(int num, int exp){
This represents the base case, where the exponent is 0
if(exp == 0){
If yes, the function returns 1
return 1; }
If exponent is negative, this throws illegal argument exception
if(exp < 0){
throw new IllegalArgumentException("Positive exponents only"); }
If exponents is positive, this calls the function recursively
else{ return (num*power(num, exp-1)); }
}