由于自己上课没注意听,下课后也没多做功课,所以当看到这道题的时候,不知道怎么下手,之后就看了书上的及知识点,然后试着做了一下,但还是有问题,就问了别人,但第六题还是没做出来
#include<stdio.h>
int main(void)
{
int factorsum(int number);
int m,n,x,s;
scanf("%d%d",&m,&n);
printf("enter two number:1<=m,n<=1000\n");
for(x=m;x<=n;x++)
{
s=x;
if(factorsum(s)==s)
printf("%d\n",s);
}
return 0;
}
int factorsum(int number)
{
int i,sum;
for(i=1,sum=0;i<number;i++)
if(number%i==0)
sum=sum+i;
return sum;
}
int main(void)
{
int factorsum(int number);
int m,n,x,s;
scanf("%d%d",&m,&n);
printf("enter two number:1<=m,n<=1000\n");
for(x=m;x<=n;x++)
{
s=x;
if(factorsum(s)==s)
printf("%d\n",s);
}
return 0;
}
int factorsum(int number)
{
int i,sum;
for(i=1,sum=0;i<number;i++)
if(number%i==0)
sum=sum+i;
return sum;
}
![](https://i-blog.csdnimg.cn/blog_migrate/9318d1d8b1663d5dd4e34cf6d3a2d003.png)