코딩테스트/[JAVA] 백준
[백준 | 1978번] 소수 찾기
냠냠쿠
2023. 8. 13. 19:06
728x90
https://www.acmicpc.net/problem/1978
📝 나의풀이
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int number ;
int count=0;
for(int i=1; i<=N; i++) {
number = scanner.nextInt();
for(int j=2; j<=number; j++) {
if(j==number) {
count++;
}
if(number%j==0) {
break;
}
}
}
System.out.println(count);
}
}
728x90