Untitled
unknown
c_cpp
8 months ago
310 B
3
Indexable
Never
#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"; } }
Leave a Comment