How to find the largest prime factor of 600851475143?

前端 未结 5 1080
挽巷
挽巷 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 19:53

    Try changing n to long long int .. and change i,j to long

    EDIT: define n like this :

    long long int n = 600851475143LL;
    

    LL - is a suffix to enforce long long type ...

提交回复
热议问题