Computer Science, asked by suhani1234567, 11 months ago

write using import java.util.package

Attachments:

Answers

Answered by Anonymous
2

Answer:

import java.util.*;

class Prime

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int a[]=new int[20];

int c=0;

System.out.println("Enter 20 numbers");

for(int i=0;i<20;i++)

{

c=0;

a[i]=sc.nextInt();

for(int j=1;j<=a[i];j++)

{

if(a[i]%j==0)

c++;

if(c==2)

{

System.out.println(a[i]+" is a prime number");

continue;

}

}

}

}

Similar questions