Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   StackOverflow? (http://www.go4expert.com/forums/stackoverflow-t26704/)

state 14Sep2011 19:18

StackOverflow?
 
Hello everyone.I have just joined the forum.
Kindly help me with the source code to find the largest prime factor of a 12-digit number.
HTML Code:

import java.io.*;
import java.util.Scanner;
class primefactor
{
    public static void main(String args[])
    {
        try{
        long num,i,j,count=0L,rem;
        long ans=0L;
        System.out.println("Enter the number whose greatest prime factor is required:");
        Scanner sc=new Scanner(System.in);
        num=sc.nextLong();
        for(i=1;i<=num;i++)
        {
       
            for(j=1;j<=i;j++)
            {
                if(i%j==0)
                    count=count+1;
               
            }
            if(count==2)
            {
                rem=num%i;
                if(rem==0)
                    ans=i;
                   
               
            }
            count=0;
        }
        System.out.println("The answer is "+ ans);}
        catch(Exception e){System.out.println(e.getMessage());}
    }
}

Thank You

ManzZup 22Sep2011 21:46

Re: StackOverflow?
 
How does StackOverflow relates here and please explain the process you have folowed so far

state 6Nov2012 19:40

Re: StackOverflow?
 
I didn't follow any process.I am not even sure that this is a stack overflow error.


All times are GMT +5.5. The time now is 02:53.