Prime No program in java

Prime no program in java

Prime no program

public class Test
{
public static void main(String[] args)
  {
   int primeno = 5;
   int temp = 0;
    for(int i = 1; i<=primeno; i++)
     {
      if(primeno%i==0)
       {
        temp++;
       }
     }
    if(temp==2)
     {
      System.out.println("Given no is prime no.");
     }
    else
     {
      System.out.println("Given no is not prime no.");
     }
  }
}

Output is

Given no is prime no.

Comments

Popular posts from this blog

Mr. Myers wants to edit the marks assigned to the questions

Genral Ability

Object Orinted Programing