题解 | 素数判断
素数判断
https://www.nowcoder.com/practice/5ab1b9690af047699e96c87dee65def4
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int count=0;
for(int i = 1; i <= n; i++){
int a = sc.nextInt();
if(a<=1){
count++;
}
if(a==2){count=0;}
for(int j=2;j<a;j++){
if(a%j==0){
count++;
}
if(count>0){
break;
}
}
if(count==0){
System.out.println("Yes");
}else{ System.out.println("No");}
count=0;
}
}
}
