Search

Q7.Print Prime numbers Model 1

package practice1;

public class PrimeNumber {

static void prime(int no)

     {

         int count = 0;

        for (int i = 1; i <= no; i++)

         {

             if (no % i == 0)

                 count++;

        }

        if (count == 2)

             System.out.println(no + " is prime");

         else

             System.out.println(no + " is not prime");

    }

     public static void main(String[] args)

    {

         prime(13); // calling

     }

}


No comments:

Post a Comment