fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int n;
  6. char check (int r);
  7.  
  8. /*
  9. *
  10. */
  11. int main(int argc, char** argv) {
  12.  
  13. int r1 = 0, r2, r3;
  14.  
  15. cout << "Below will be printed the Proper Divisors" << endl;
  16.  
  17. sleep(5);
  18.  
  19. for (n = 20; n >= 20 && n <=30; n++) {
  20.  
  21. cout << "Integer " << n << ":";
  22.  
  23. for (int d = 1; d < n; d++) {
  24.  
  25. if (n % d == 0) {
  26.  
  27. r1 = r1 + d;
  28. cout << d << ", ";
  29. }
  30. }
  31.  
  32. cout << " = " << r1 << ". It is " << check(r1) << endl;
  33. r1 = 0;
  34. }
  35.  
  36.  
  37. return 0;
  38. }
  39.  
  40. char check (int r) {
  41.  
  42. if (r < n){
  43.  
  44. cout << "Deficient";
  45. }
  46.  
  47. else if (r == n) {
  48.  
  49. cout << "Perfect";
  50. }
  51.  
  52. else {
  53. cout << "Abundant";
  54. }
  55. }
Success #stdin #stdout 0.02s 2680KB
stdin
Standard input is empty
stdout
Below will be printed the Proper Divisors
Integer 20:1, 2, 4, 5, 10, Abundant = 22. It is @
Integer 21:1, 3, 7, Deficient = 11. It is @
Integer 22:1, 2, 11, Deficient = 14. It is @
Integer 23:1, Deficient = 1. It is @
Integer 24:1, 2, 3, 4, 6, 8, 12, Abundant = 36. It is @
Integer 25:1, 5, Deficient = 6. It is @
Integer 26:1, 2, 13, Deficient = 16. It is @
Integer 27:1, 3, 9, Deficient = 13. It is @
Integer 28:1, 2, 4, 7, 14, Perfect = 28. It is @
Integer 29:1, Deficient = 1. It is @
Integer 30:1, 2, 3, 5, 6, 10, 15, Abundant = 42. It is @