这个结果是对的但是就是不通过
查看原帖
这个结果是对的但是就是不通过
975182
YUNNNN楼主2023/12/7 20:58
package _issue;
//求阶乘之和
import java.math.BigInteger;
import java.util.Scanner;

public class _1 {
    public static  void main(String[]args)
    {
        Scanner s=new Scanner(System.in);
        int num=s.nextInt();
        BigInteger sum=new BigInteger("0");
        for (int i = 1; i <= num; i++) {
            BigInteger a=new BigInteger("1");
            for (int j = 1; j <= i; j++) {
                a=a.multiply(BigInteger.valueOf(j));
            }
            sum=sum.add(a);
        }
        System.out.println(sum);
    }
}
2023/12/7 20:58
加载中...