- duanjiajun's blog
求素数
- 2023-8-12 10:25:09 @
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
bool isPrime = true; // isPrice:素数
if (n < 2) {
cout << "No" << endl;
} else {
nn = sqrt(n);
for (int i = 2; i <= nn; i++) {
if (n % i == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
//cout << (isPrice ? "Yes" : "No") << endl;
}
return 0;
}