Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /* Part 4 */
- int main() {
- int n;
- printf("Enter an integer: ");
- while(scanf("%d", &n)) {
- if(n <= 0) break;
- else printf("Divisors of %d:", n);
- int i, s = 0;
- for(i = 1; i < n; i++) {
- if(n % i == 0) {
- printf(" %d", i);
- s += i;
- }
- }
- if(n == s) printf("\n%d is a perfect number.", n);
- else if(n < s) printf("\n%d is an abundant number.", n);
- else printf("\n%d is a deficient number.", n);
- printf("\n\nEnter an integer: ");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment