我在java中创建了方法exp,但是当我处理方法时,我总是得到相同的答案
public class Recursion {
private double x;
private int n;
// Method exp(x,n)
public static double exp(double x,int n){
if(n > 1){
n = n-1;
x = x * x;
exp(x,n);
}
else if (n == 1);
return x;
}
public static void main (String[]args){
System.out.println(exp (2.5,4));
}
}