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;
}
else
divider++;
if (num == 1)
break;
}
}
小さい数値を入力し、BigInt lib を使用しない場合、このプログラムは正常に動作します。どんな助けでも大歓迎です:D