Answers

2014-12-04T12:01:06+05:30
I'm writing this in simple way so you are able to understand.
A Prime Number is that number which is divisible by only 1 and itself.
Example: 17.It is only divisible by 1 and 17 ,hence it is a prime number.

class checkPrime {
public static void main(int number)
{
int counter=0;
for(int i=1; i<=number; i++)
{
   if ( number%i==0 )
{
   counter++;
}
}
if(counter==2)
{
System.out.println(" Number is Prime");
}
else 
{
System.out.println("Number is not Prime");
}
counter=0;
}
}

0