Find Given number is Prime Or NotPrime number in Java:

Prime numberis a number that is greater than 1 and divided by 1 or itself only. In other words, prime numbers can’t be divided by other numbers than itself or 1. For example 2, 3, 5, 7, 11, 13, 17…. are the prime numbers.

`class PrimeorNot`

{

public static void main(String args[])

{

int findprimeornot = 8;

int m = findprimeornot/2;

int flag = 0;

if(findprimeornot == 0 || findprimeornot == 1)

System.*out*.println("Not a Prime Number");

else

{

for(int i=2;i<=m;i++)

{

if(findprimeornot%i == 0)

{

flag = 1;

break;

}

}

if(flag == 0)

System.*out*.println("Is a Prime Number");

else

System.*out*.println("Is Not A Prime Number");

}

}

}