1.
#include<stdio.h>
int main()
{
int a, i, m;
printf("The answer is:\n");
for(a = 1; a < 1000; a++)
{
for(m = 0, i = 1; i <= a/2; i++)
{
if(!(a % i))
{
m += i;
}
}
if(m == a)
{
printf("%4d\n",a);
}
}
return 0;
}
2.
#include<stdio.h>
int main()
{
int a, i, b, n;
printf("The answer is :\n");
for(a =1; a < 3000; a++)
{
for(b = 0, i = 1; i <= a / 2; i++)
{
if(!(a % i))
{
b+=i;
}
}
for(n = 0, i = 1; i <= b / 2; i++)
{
if(!(b % i))
{
n+=i;
}
}
if(n == a && a < b)
{
printf(" %4d..%4d",a,b);
}
}
printf("\n");
return 0;
}