数学中的阶乘

public class Class_2 {


    static int jiecheng(int n){
        if(n <= 1){
            return 1; 
        }else{
            return n*jiecheng(n - 1);  //利用的是阶乘和递归
        }
    }

    public static void main(String[] args) {
        int  zhi = jiecheng(5);
        System.out.println(zhi);
    }

}

猜你喜欢

转载自blog.csdn.net/qq_30443907/article/details/82143681