Guest User

Untitled

a guest
Jun 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment