还有个算法:
#include <stdio.h>
long MAX1=10000;
int complete(long x)
{
long i,s=1;
for (i=2;i<=x/2;i++)
if (x%i==0)s+=i;
if (x==s)
return 1;
else
return 0;
}
void main()
{
long t,i;
for (t=2;t<=MAX1;t=t+2)
if (complete(t))
{
printf(" %ld =1",t);
for (i=2;i<=t/2;i++)
if (t%i==0)printf("+ld",i);
printf("\n");
}
}