0% found this document useful (0 votes)
31 views

b6 Dsa

This Java code uses a Scanner to input an integer n and then an array of n integers, it then checks each element of the array for prime numbers and prints out any primes.

Uploaded by

Thu Hòa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

b6 Dsa

This Java code uses a Scanner to input an integer n and then an array of n integers, it then checks each element of the array for prime numbers and prints out any primes.

Uploaded by

Thu Hòa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;

public class b6{

public static void main(String[] args){

Scanner sc = new Scanner(System.in);


int n= sc.nextInt();
int a[] = new int[100];
for(int i= 0; i <n; i++){
a[i] = sc.nextInt();
}
for (int i = 0; i < n; i++){
for( int j = 2;j < a[i];j++){
if(a[i]%j==0){
}else
{
System.out.print(a[i]+" ");
}
}
}
}
}

You might also like