Untitled
unknown
c_cpp
2 years ago
310 B
12
Indexable
#include <iostream>
#include <math.h>
using namespace std;
bool IsPrime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x % i == 0) return false;
}
return true;
}
int main() {
int x;
cin >> x;
IsPrime(x);
if (IsPrime(x) == 1) {
cout << "YES";
}
else {
cout << "NO";
}
}Editor is loading...
Leave a Comment