Java

Prime Number Program In Java

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");
  }

 
 }
}

Related Posts

Table Of Contents

;