Write a recursive method that computes the value of xn.
code:
class Main {
public static int multiplyRecursive(int x, int n){
if(n==1){
return x;
}else{
return x+multiplyRecursive(x,n-1);
}
}
public static void main(String[] args) {
int res = multiplyRecursive(3,5);
System.out.println(res);
}
}
Get Answers For Free
Most questions answered within 1 hours.