package com.company.test3;
public class MyFactoralDemo {
public static void main(String[] args) {
int result = getJc(5);
System.out.println(result);
}
private static int getJc(int i) {
//一定要有出口
if(i==1){
return 1;
}
else {
//总结好规则
return i*getJc(i);
}
}
}
java递归练习
最新推荐文章于 2024-09-05 11:00:53 发布