Write a program that asks the user to enter an integer making sure it is a positive number (a negative integer should not be accepted), and checks if this number is ABUNDANT. A number n is said to be abundant when the sum of its divisors (including the number itself) is greater than its double (2*n).
Example: 12 is abundant since (1 + 2 + 3 + 4 + 6 + 12 > 24)
Difficulty level

This exercise is mostly suitable for students
#include <stdio.h>
int main()
{
int n, i, sum;
sum=0;
do{
printf("Enter n: ");
scanf("%d",&n);
}while(n<=0);
for(i=1; i<=n;i++)
if(n%i==0)
sum+=i;
if(sum>2*n)
printf("%d is an abundant number\n",n);
else
printf("%d is not an abundant number\n",n);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
