これは私のコードです:
#include <iostream>
using namespace std;
int main()
{
long int x = 1;
long int res;
while (x<600851475143)
{
x++;
if(600851475143%x==0)
{
res=x;
cout<<x<<"\n";
}
}
}
何が問題なのかわかりませんが、次の出力が得られます。
839
1471
6857
59569
104441
486847
1234169
5753023
10086647
87625999
408464633
716151937
-716151937
-408464633
-87625999
-10086647
-5753023
-1234169
-486847
-104441
-59569
-6857
-1471
-839
-71
-1
Floating point exception
Process returned 136 (0x88) execution time : 156.566 s
Press ENTER to continue.
そして、600851475143を13195に置き換えると[例にありました]...正常に動作し、次の出力が得られます:
5
11
55
11149
Process returned 0 (0x0) execution time : 0.005 s
Press ENTER to continue.
何が間違っているのかわかりません...:/
おそらく、以前のプログラムは正しく実行されませんでした...最初にintで試してから、long intに変更しました...違いはありません...