package sushudigui; import java.util.Scanner; public class digui {
public static void main(String[] args){
System.out.println("输入n,按回车:");
Scanner s = new Scanner(System.in);
Integer n = Integer.parseInt(s.next());
Integer re = factorial(1, n);
System.out.println(re);
}
public static Integer factorial(Integer a, Integer b){
if(b == 1){
return a * b;
}else{
return a * b * factorial(a, b-1);
}
} }
相关文章
- golang结构体struct递归引用异常解决办法: invalid recursive type: xxx refers to itself-解决方法:将这个Child字段指向的类型Person改为指针类型, 即 Child *Person ; 因为go语言中的任何一个指针类型都是可以确定其大小的!
- sed的N;P用法
- 求N的因子之和。
- JL 杰理 AC692N系列TWS 蓝牙音箱 开发
- 【弄nèng - Activiti6】Activiti6入门篇(二十二)—— 使用activiti-app创建流程MODEL
- 火兰hillstone与fortigate之ipsec v.p.n连接实践
- 报错:org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
- org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [41] did not match expected type [java.lang.Integer (n/a)];
- 报错org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet"
- PHP递归重新排序无限级分类数组