8, java数据结构和算法: 从阶乘来看递归的调用

直接上代码

public class RecursionDemo {
    //从阶乘看 递归的调用机制
    public static void main(String[] args) {
        System.out.println(recursion(4));
    }

    public static int recursion(int n){
        if(n ==1){
            return 1;
        }else{
            return recursion(n-1)*n;
        }
    }
}

调用机制:

posted @ 2020-06-04 13:41  死不了好气呦  阅读(143)  评论(0编辑  收藏  举报