daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. /* Part 4 */
  4.  
  5. int main() {
  6.   int n;
  7.   printf("Enter an integer: ");
  8.  
  9.   while(scanf("%d", &n)) {
  10.     if(n <= 0) break;
  11.     else printf("Divisors of %d:", n);
  12.  
  13.     int i, s = 0;
  14.     for(i = 1; i < n; i++) {
  15.       if(n % i == 0) {
  16.         printf(" %d", i);
  17.         s += i;
  18.       }
  19.     }
  20.  
  21.     if(n == s) printf("\n%d is a perfect number.", n);
  22.     else if(n < s) printf("\n%d is an abundant number.", n);
  23.     else printf("\n%d is a deficient number.", n);
  24.  
  25.     printf("\n\nEnter an integer: ");
  26.   }
  27.  
  28.   return 0;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top