Simple Java Program To Find Whether Number Is Prime or Not



/* Write a program to Find whether number is Prime or Not. */

class PrimeNo{

      public static void main(String args[]){

          int num = Integer.parseInt(args[0]);

         int flag=0;

         for(int i=2;i

             if(num%i==0)

              {

                 System.out.println(num+" is not a Prime Number");

                 flag = 1;

                 break;

              }

         }

         if(flag==0)

             System.out.println(num+" is a Prime Number");

    }

}

0 komentar:

Post a Comment

Related Posts with Thumbnails
GiF Pictures, Images and Photos