ProjectEuler
Problem 3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
class prime{
public static void main(String args[]){
Scanner nn=new Scanner(System.in);
long n=nn.nextLong();
int i=2;
while(n>1)
{
if(n%i==0)
{
System.out.print(i+" ");
n/=i;
}
else
i++;
}
}
}
Output
71 839 1471 6857
No comments:
Post a Comment