package homewordk1;
import java.math.*;
public Factorial {
public static void main(String args[]){
BigInteger fact=new BigInteger("1"),sum=new BigInteger("0");
int i=1;
do{
fact=fact.multiply(new BigInteger(i+""));
sum=sum.add(fact);
++i;
}while(i<=100);
System.out.println(sum.toString());
}
}

本文展示了一个使用Java实现的程序,该程序计算从1到100的阶乘序列的总和。通过BigInteger类处理大数值运算,避免了整数溢出的问题,实现了精确的数学计算。
1533





