# include
void main()
{
int num;
printf("Input m:");
scanf("%d",&num);
if(isPerfect(num)) printf("%d is a perfect number.\n",num);
else printf("%d is not a perfect number.\n",num);
}
int isPerfect(int n)
{
int i,j,s;
for(i = 2; i<=n;i++)
{ s=0;
for(j=1;j
if(i%j==0) s=s+j;
if(s==i) return 1;
}
return 0;
}
希望对您有帮助