Untitled

mail@pastecode.io avatar
unknown
plain_text
13 days ago
322 B
1
Indexable
Never
#include <iostream>
#include <cmath>
using namespace std;
bool IsPrime(int x)
{
	float b;
	int l=0;
	b = sqrt(x);
	for (int i = 2; i < b; i++) {
		if (x % i == 0) {
			return 0;
		}
	}
	return 1;
}
int main()
{
	int x;
	cin >> x;
	if (IsPrime(x) == 0) {
		cout << "NO";
	}
	else { cout << "YES"; }
}
Leave a Comment