Prime Number Program In Java
Oct 2, 2013
Make sure to subscribe to our newsletter and be the first to know the news.
Oct 2, 2013
Make sure to subscribe to our newsletter and be the first to know the news.
class PrimeNumber
{
public static void main(String[] args)
{
int number, i, rem;
boolean check=true;
number=14; //Taking a prime number for calculations
for(i=2;i<=number/2;i++)
{
rem=number%i;
if(rem==0)
{
check=false;
break;
}
}
if(check)
{
System.out.println(number+ " is Prime Number");
}
else
{
System.out.println(number + " is not Prime Number");
}
}
}