write a program to accept any 20 number and display only those number which are prime .
Hind: a number is said to be Prime if it is only divisible by 1 and the number itself .
Answers
Answered by
5
Answer:
importJava.util.*
public class prime
{
public static void main()
{
Scanner sc=new Scanner(System.in)
int i;
for(i=1;i>=20;i++)
{
int a=sc.nextInt();
int k;int s=0;
for(k=1;k>=a;k++)
{
if(a%k==0)
{
s++;
}
}
if(s==2)
{
System.out.println(a);
}
}
}
}
Similar questions