The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
http://projecteuler.net/problem=3
public class PrimeNum {
public static void main(String args[]){
double l=600851475143.0;
for(double i=2;i<l;i++){
if(l%i==0){
if(isPrime(l/i)){
System.out.println("l%i="+l/i);
break;
}
}
}
}
public static boolean isPrime(Double n){
for(int i = 2; i * i <= n; i++){
if(n % i == 0)
return false;
}
return true;
}
}
Answer:
| 6857 |