0

我在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));
    }  
} 
4

0 回答 0