Computer Science, asked by Anonymous, 10 months ago

WAP in Java to check whether a number is prime or not..​

Answers

Answered by IƚȥSɯҽҽƚCαɳԃყ
9

Answer:

Refer to the attached picture!☺

Attachments:
Answered by crpiyushbansal
0

Answer:

public class PRIME_NOT_PRIME {

   public static void main(String[] args) {

       Scanner sc=new Scanner(System.in);

       System.out.println("ENTER THE NUMBER");

       int num=sc.nextInt();

       boolean condition=true;

       for(int i=2; i<num;i++){

           if(num%i==0){

               condition=false;

               break;

           }

       }

       if(condition && num>=3){

           System.out.println(num+" IS A PRIME NO.");

       }

       else{

           System.out.println(num+" IS NOT A PRIME NO.");

       }

   }

}

Explanation:

Similar questions