Find Given number is Prime Or Not

Prime number in Java: Prime number is 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");        }    }}`

## More from Pandiyan Mani

Knowledge is everything.Check out my app at https://play.google.com/store/apps/details?id=com.vibe.britevibe