Problem #3 on Project Euler is:
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085147514
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 60085147514
This one works perfectly!!
public class Puzzle3 { public static void main(String ar[]) { Long i=new Long("1"); Long p=new Long("600851475143"); Long f=new Long("1"); while(p>=i) { if(p%i==0) { f=i; p=p/i; int x=1; i=(long)x; } i=i+2; } System.out.println(f); }
}