How to find the largest prime factor of 600851475143?

前端 未结 5 1069
挽巷
挽巷 2021-01-16 19:08
#include 
main()
{
    long n=600851475143;
    int i,j,flag;
    for(i=2;i<=n/2;i++)
    {
        flag=1;
        if(n%i==0)//finds factors backw         


        
5条回答
  •  时光说笑
    2021-01-16 20:00

    On 32-bit machine long range from -2,147,483,648 to 2,147,483,647 and On 64-bit machine its range is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (NOTE: This is not mandated by C standard and may vary from one compiler to another).
    As OP said in comment he is on 32-bit, 600851475143 goes out of range as it is not fit in the range of long.

提交回复
热议问题