L10 - C

public
yeskendir.sultanov Mar 29, 2024 Never 92
Clone
C++ l10c.cpp 26 lines (23 loc) | 415 Bytes
1
#include <bits/stdc++.h>
2
3
using namespace std;
4
5
bool isPrime(int n) {
6
if (n == 1) {
7
return false;
8
}
9
for (int i = 2; i * i <= n; ++i) {
10
if (n % i == 0) {
11
return false;
12
}
13
}
14
return true;
15
}
16
17
int main() {
18
int n;
19
cin >> n;
20
if (isPrime(n)) {
21
cout << "YES";
22
} else {
23
cout << "NO";
24
}
25
return 0;
26
}
27
28
29