用递归的方法计算n!的值,n从键盘输入
收起
知与谁同
2018-07-19 17:33:18
1812
0
1
条回答
写回答
取消
提交回答
-
class TestFive{
public static void main(String[] args) throws IOException {
Scanner in=new Scanner(System.in);
int n = in.nextInt();
System.out.println(jiecheng(n));
}
public static int jiecheng(int n){
if(n == 1){
return 1;
}else{
return n*jiecheng(n-1);
}
}
}
2019-07-17 22:55:00