Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool IsPrime(int n) {
- int divisors_counter = 0;
- for (int divisor = 1; divisor <= n; divisor++) {
- if (n % divisor == 0) {
- divisors_counter++;
- }
- }
- return divisors_counter == 2;
- }
- int main() {
- int n;
- cin >> n;
- if (isPrime(n)) {
- cout << "YES\n";
- } else {
- cout << "NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement