#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<math.h>
int
test(int n);
void main()
{
int i,lower,upper,temp;
clrscr();
printf("Enter the range\n");
printf("\tLower
Bound?");
scanf("%d",&lower);
printf("\tUpper
Bound?");
scanf("%d",&upper);
if(lower>upper)
{
temp=lower;
lower=upper;
upper=temp;
}
printf("Number\tType\n");
for(++lower;lower<upper;lower++)
switch(test(lower))
{
case
0:printf("%d\tperfect\n",lower);break;
case
1:printf("%d\tAbudant\n",lower);break;
case
2:printf("%d\tdeficiant\n",lower);break;
}
getch();
}
int
test(int n)
{
int i,sum=0;
for(
i=2;i<n;++i)
if(n%i==0)
sum+=i;
printf("%d",sum);
getch();
if(sum==n)
return 0;
else
if(sum>n)
return 1;
else
return 2;
}
0 comments:
Post a Comment