题目:计算1!+2!+3!+...+200!
import java.util.*;
import java.math.*;
public class bignumber
{
public static void main(String[] args) throws Exception
{
BigInteger bigInteger1=new BigInteger("11111111111111111111111111111");
BigInteger bigInteger2=new BigInteger("99999999999999999999999999999");
//BigInteger b=BigInteger.valueOf(a);将参数转换为指定的大数类型
//bigInteger1=bigInteger1.add(bigInteger2);加
//subtract();减
//multiply();乘
//divide();除(取整)
//pow();乘方
//remainder();取余
//gcd(); 最大公约数
//abs(); 绝对值
//negate();取反数
//mod(); a.mod(b)=a%b=a.remainder(b);
//max(); min();
/*Scanner cin=new Scanner(System.in);// 读入
while(cin.hasNext()) //等同于!=EOF
{
int n;
BigInteger m;
n=cin.nextInt(); //读入一个int;
m=cin.BigInteger();//读入一个BigInteger;
System.out.print(m.toString());
}*/
BigInteger s=BigInteger.valueOf(0);
for(int i=1;i<=200;i++)
{
BigInteger w=BigInteger.valueOf(1);
for(int j=1;j<=i;j++)
w=w.multiply(BigInteger.valueOf(j));
s=s.add(w);
}
System.out.print(s.toString());
}
}
5万+

被折叠的 条评论
为什么被折叠?



