Computer Science, asked by ishaansingh9752, 6 months ago

WAP in java to check the entered number is PrimeAdam number or not
(write program using Scanner or BufferReader)

Answers

Answered by trilokiindiawale
2

Answer:

package prime;

import java.util.Scanner;

public class prime

{

public static void main(String[] args)

{

String yn;

do

{

int f=0;

Scanner s=new Scanner(System.in);

System.out.println("Enter any no.to find whether it is prime or not");

int n=s.nextInt();

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

{

if(n%i==0)

{

f++;

}

}

if(f==2)

{

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

}

else

{

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

System.out.println("Do u want to continue ");

yn=s.next();

}while(yn.equals("y")||yn.equals("Y"));

}

}

Explanation:

It is very simple to understand.

Similar questions