递归(栈)

 Java方法——递归

 package method;
 
 public class Demon04 {
        //递归思想
    public static void main(String[] args) {
        //阶乘
        System.out.println(f(5));
 
    }
    public static int f(int n){
        if(n==1){//递归出口
            return 1;
        }else{
            return n*f(n-1);
        }
    }
 }
 

 

相关文章:

  • 2021-11-11
  • 2022-12-23
  • 2021-06-22
  • 2021-06-26
  • 2022-01-01
  • 2021-09-22
猜你喜欢
  • 2021-09-25
  • 2021-09-19
  • 2021-09-15
  • 2022-03-01
  • 2021-12-01
  • 2021-04-18
  • 2021-11-19
相关资源
相似解决方案