首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我想在JAVA中取出存储在BigInteger中的大数字的最后一位

我想在JAVA中取出存储在BigInteger中的大数字的最后一位
EN

Stack Overflow用户
提问于 2018-08-01 20:20:58
回答 4查看 800关注 0票数 0
代码语言:javascript
运行
复制
import java.math.BigInteger;
import java.util.Scanner;

public class LastFact
{
    // Returns Factorial of N
    static BigInteger factorial(int N)
    {
        // Initialize result
        BigInteger f = new BigInteger("1"); // Or BigInteger.ONE

        // Multiply f with 2, 3, ...N
        for (int i = 2; i <= N; i++)
            f = f.multiply(BigInteger.valueOf(i));

        return f;
    }

    // Driver method
    public static void main(String args[]) throws Exception
    {
        int N = 300;

        System.out.println(factorial(N));
    }
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51633188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档