The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
______________________________________________________________________________
Solution:
public class Problem_3{ public static void main(String[] args){ long a=600851475143l; long prime=0; for(long i=1l;i<a;a++){ long temp=0l; if(a%i==0){ if(isPrime(i)){ System.out.println("Prime factor is "+i); } } } } static boolean isPrime(long a){ for(long i=2l;i<a;i++){ if(a%i==0) return false; } return true; } }
No comments:
Post a Comment