#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system(“pause”) or input loop */
//一个数如果恰好等于它的因子之和,这个数就称为完数。例如,6是完数,因为6=1+2+3。编程求1000之内的所有完数,并按下面格式输出其因子:6 its factors are 1,2,3
int main(int argc, char *argv[]) {
int m,s,i;
for(m=2;m<1000;m++)
{
s=1;
for(i=2;i<=m/2;i++)
{
if(m%i0) s+=i;
}
if(ms)
{
printf("%d its factors are “,m);
for(i=1;i<m/2;i++)
{
if(m%i==0) printf(”%d,",i);
}
printf("%d",m/2);
printf("\n");
}
}
return 0;
}