About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, April 26, 2010

JAVA(Prime Number)---------------------

//Prime Number


import java.io.*;

class Prime

{

public static void main(String args[])

{





int num=0,flag=0;

System.out.println("Please Enter Your NUmber..");

try

{

DataInputStream dis=new DataInputStream(System.in);

num=Integer.parseInt(dis.readLine());

}

catch(Exception e){}



for(int i=2;i

{

if(num%i==0)

{

flag=1;

break;

}

else

{

flag=0;

}

}



if(flag==0)

{

System.out.println("Number is Prime NUmber..");

}

else

{

System.out.println("Number is Not Prime NUmber..");

}



}

}

No comments: