Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.      
  4. int sumadivisores(int n) {
  5.   int suma=0;
  6.   for (int i=1; i<n; ++i) {
  7.     if (n%i==0) suma+=i;
  8.   }
  9.   return suma;
  10. }
  11.      
  12. int main() {
  13.   int n;
  14.   while (cin >> n) {
  15.     int suma= sumadivisores(n-2) + sumadivisores(n) + sumadivisores(n+2);
  16.     if (suma==n) cout << n << ": popiropis" << endl;
  17.     else if (suma%n==0) cout << n << ": " << suma/n << "-popiropis" << endl;
  18.     else cout << n << ": res" << endl;
  19.   }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement