Advertisement
Josif_tepe

Untitled

Feb 15th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin >> n;
  7.     int number_of_divisors = 0;
  8.     for(int i = 1; i <= n; i++) {
  9.         if(n % i == 0) {
  10.             number_of_divisors++;
  11.         }
  12.     }
  13.     if(number_of_divisors == 2) {
  14.         cout << "PRIME" << endl;
  15.     }
  16.     else {
  17.         cout << "NOT PRIME" << endl;
  18.     }
  19.     return 0;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement