Advertisement
Josif_tepe

Untitled

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