如何表示大于 (10^6) 的整数!用于在java中求解方程

发布于 2024-12-23 10:32:08 字数 123 浏览 3 评论 0原文

我们如何求解具有 N! 的方程?其中的常量,其中 N 的范围可以是 1<=N<=10^6 BigInteger 最多只能执行 128 位,对吗?

即使两边都取对数,留下的值也比 BigInteger 大。

How can we solve equations having N! constants in it , where N can be of range 1<=N<=10^6
BigInteger can only perform upto 128 bits right?

Even when one do logarithm on both sides, it leaves values bigger than BigInteger.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

揪着可爱 2024-12-30 10:32:08

不,BigInteger 可以处理任意大小的整数(受内存限制)。来自文档

不可变的任意精度整数。

(强调我的观点。)

这并不是说 BigInteger 一定是满足您需求的正确答案,但在做出决定之前了解其真正的功能是值得的。

No, BigInteger can handle arbitrary sizes of integer (limited by memory). From the documentation:

Immutable arbitrary-precision integers.

(Emphasis mine.)

That's not to say that BigInteger will necessarily be the right answer to your requirements, but it's worth being aware of its real capabilities before deciding.

抚笙 2024-12-30 10:32:08

即使两边都取对数,留下的值也比 BigInteger 大。

让 N=10^6

log(N!) ~ NlogN - N [Stirling's approximation]

        ~ 13e6

这可以(很容易)适合 int

Even when one do logarithm on both sides, it leaves values bigger than BigInteger.

let N=10^6

log(N!) ~ NlogN - N [Stirling's approximation]

        ~ 13e6

this can (easily) fit in int

悲凉≈ 2024-12-30 10:32:08

BigInteger 的实现限制为大约 2 ^ 21 亿位或大约 256 MB。鉴于其使用 int 位长度,这一数字不太可能增加。

The implementation of BigInteger is limited to around 2 ^ 2.1 billion bits or about 256 MB. Given its used of int for bit lengths, this is unlikely to increase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文