- 소수 찾기
문제출처 : https://www.acmicpc.net/problem/1978
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class baekjoon1978 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static int N,result=0;
static int[] arr;
static boolean temp;
static boolean isPrime(int num){
boolean flag=true;
int cnt=0;
for(int i=1;i<num;i++){
if(num%i==0){
cnt++;
}
}
if(cnt!=1){
flag=false;
}
return flag;
}
public static void main(String args[])throws IOException{
N = Integer.parseInt(br.readLine());
arr = new int[N];
st = new StringTokenizer(br.readLine()," ");
for(int i=0;i<N;i++){
arr[i] = Integer.parseInt(st.nextToken());
temp = isPrime(arr[i]);
if(temp==true){
result++;
}
}
System.out.println(result);
}
}