我是靠谱客的博主 跳跃石头,这篇文章主要介绍java 之BigInteger类实现计算大整数的阶乘,现在分享给大家,希望可以做个参考。

package s1;

import java.math.*;
import java.util.*;
public class A7 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int x=cin.nextInt();
        BigInteger a=BigInteger.valueOf(x);
        BigInteger b=BigInteger.ONE;
        BigInteger s=BigInteger.ONE;
        for(BigInteger i=BigInteger.ONE;i.compareTo(a)<=0;i=i.add(b)){
            s=s.multiply(i);
        }
        System.out.println(s);
        cin.close();
    }
}

最后

以上就是跳跃石头最近收集整理的关于java 之BigInteger类实现计算大整数的阶乘的全部内容,更多相关java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(139)

评论列表共有 0 条评论

立即
投稿
返回
顶部