且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法计算大的因子,即大约n <500

更新时间:2023-08-31 11:58:52

你有没有为此编写任何代码?或者要求我们编写代码?

您可能面临数据类型大小限制。


问候

Dheeraj Joshi


注意:您可以尝试long long int。
Have you written any code for this? Or asking us to write the code?
You might face datatype size limitation.

Regards
Dheeraj Joshi

Note: You may try long long int.


long long int将在n = 30时进行bork。所以...仅限定制长整数。

除以10的数字,如p * 10,可以用p代替,跟踪''丢失''尾随零。
long long int will bork on n=30. So... custom long integer only.
Numbers that divide by 10, like p*10 may be replaced with p, keeping track of ''lost'' trailing zeroes.


执行此操作的唯一方法是编写自己的长整数,可以处理足够大的数字。如果你正在使用C ++,好消息是这是一个非常常见的任务,因此已经有一些公平的无限精度整数实现。


如果你google一个合适的主题你会在网上找到很多代码snipets以及一些实际的实现,比如SourceForge中提供的BigInt。
The only way to do this is to write your own long integer that can handle large enough numbers. If you are using C++ the good news is that this is quite a common task so there are already a fair few unlimited precision integer implementations out there.

If you google an appropriate topic you will find lots of code snipets across the web as well as some actual implementations such as BigInt available in SourceForge.