package com.method;
public class Demo05 {
public static void main(String[] args) {
//====================递归 =================
// A方法调用A方法,自己调用自己
Demo05 demo05=new Demo05();
System.out.println(demo05.f(5));
}
//阶乘:5*4*3*2*1
public static int f(int n){
if(n==1){
return 1;
}else {
return n*f(n-1);
}
}
}
JAVA 递归
最新推荐文章于 2024-07-24 17:27:32 发布