#include <stdio.h>
#include <math.h>
#define N 3000
int factorsum( int n )
{
int i, sum = 1;
int m;
m = (int)sqrt(n);
for( i = 2; i <= m; i ++ )
{
if( n % i == 0 )
{
sum += i + n / i;
}
}
if( m * m == n )
sum -= m;
return sum;
}
void main()
{
int num1, num2, temp, lastresult = 0;
for( num1 = 2; num1 <= N; num1 ++ )
{
if( num1 == lastresult )
continue;
num2 = factorsum(num1);
if( num2 > 1 && num2 <= N )
{
temp = factorsum(num2);
if( temp == num1 )
{
lastresult = num2;
printf( "%d\t%d\n", num1, num2 );
}
}
}
getch();
}