我试图在C++变量中放置一个大数字.号码是600851475143
我尝试了unsigned long long int但是错误地说它常量太大了.然后我尝试了一个名为BigInt的bigInt库 - > http://mattmccutchen.net/bigint/
问题是我无法编译代码,因为我收到很多关于lib的错误.
未定义的引用`BigInteger :: BigInteger(int)'< - 很多这些.
到目前为止,这是我的代码:
#include "string"
#include "iostream"
#include "bigint/NumberlikeArray.hh"
#include "bigint/BigUnsigned.hh"
#include "bigint/BigInteger.hh"
#include "bigint/BigIntegerAlgorithms.hh"
#include "bigint/BigUnsignedInABase.hh"
#include "bigint/BigIntegerUtils.hh"
using namespace std;
int main() {
//unsigned long int num = 13195;
//unsigned long long int num = 600851475143;
BigInteger num = 13195;
int divider = 2;
//num = 600851475143;
while (1) {
if ((num % divider) == 0) {
cout << divider << '\n';
num /= divider;
} …Run Code Online (Sandbox Code Playgroud)