解题思路:
注意事项:
参考代码:
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二级辅导-同因查找 (C语言代码)浏览:562 |
小九九 (C语言代码)浏览:822 |
拆分位数 (C语言代码)浏览:1328 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:1095 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:524 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:937 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:641 |
用筛法求之N内的素数。 (C++代码)浏览:693 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:533 |
P1000 (C语言代码)浏览:877 |