Untitled

mail@pastecode.io avatar
unknown
c_cpp
17 days ago
310 B
0
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