java的bigInteger实现了c++的高精度阶乘
查看原帖
java的bigInteger实现了c++的高精度阶乘
505424
daybreak2626楼主2021/5/12 10:32
import java.math.BigInteger;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        BigInteger b = BigInteger.valueOf(0);
        int n = sc.nextInt();

        for(int i=1;i<=n;i++){
            BigInteger a = BigInteger.valueOf(1);
            for(int j = 1;j<=i;j++){
                BigInteger c = BigInteger.valueOf(j);
                a = a.multiply(c);
            }
            b =  b.add(a);
        }
        System.out.println(b);
    }
}
2021/5/12 10:32
加载中...