java - The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? -


my program not working on eclipse.. , dont know whats wrong it.. plz help.. , plz tell reason well.

 public class problemthree {          public static void main(string args[])         {             long a=0l, z=0l;             long n=600851475143l;              for(long i=2;i<=n ;++i)             {                 if(600851475143l % i==0)                 {                     a=i;                      if(a%2==0)                         {;  }                     else if(a%3==0)                         { ;}                     else if(a%5==0)                         { ;}                     else if(a%7==0)                         { ;}                     else if (a>z)                     {                          z=a;                     }                  }              }              system.out.println(z);          }     } 

thank guys feedback have solved question myself following code.. :)

public class problemthree {

public static void main(string args[]) {      long n=600851475143l;      for(long i=2;i<n ;++i)     {         while(n % i==0)         {//for yes             n=n/i;          }         }     system.out.println(n); } 

}


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -