解题思路:
注意事项:
参考代码:
import java.math.BigInteger; import java.util.*; public class Main { public static BigInteger fact(int n) { if(n==0) return BigInteger.ZERO; if(n==1) return BigInteger.ONE; else return BigInteger.valueOf(n).multiply(fact(n-1)); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); BigInteger BigInt=BigInteger.valueOf(0); for(int i=1;i<=n;i++) { BigInt=BigInt.add(fact(i)); } System.out.println(BigInt); } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:862 |
【计算两点间的距离】 (C语言代码)浏览:1493 |
The 3n + 1 problem (C语言代码)浏览:553 |
C语言训练-亲密数 (C语言代码)浏览:682 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:549 |
A+B for Input-Output Practice (VII) (C语言代码)浏览:528 |
【亲和数】 (C语言代码)浏览:599 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:517 |
字符串输入输出函数 (C语言代码)浏览:2495 |
C二级辅导-分段函数 (C语言代码)浏览:601 |