//用n对2到sqrt(n)取余,期间若有余数为0,return false; 否则 return true #include <stdio.h> #include <iostream> #include <cmath> using namespace std; bool judge(int n) { if (n < 2) { return false; } for (int i = 2; i <= sqrt(n); i++) { // 注:<= if (n % i == 0) { return false; } } return true; } int main() { int n; while (scanf("%d", &n) != EOF) { if (judge(n)) { printf("yes\n"); } else { printf("no"); } } return 0; }