原来,素数是被排除在定义外啊!!!让你不看题!!!
#include<stdio.h>
#include<math.h>
int xx(int x)
{
int sum=0;
while(x!=0)
{
sum+=x%10;
x=x/10;
}
return sum;
}
int yy(int n)
{
int i,sum=0,temp,t=n;
for( i = 2; i*i <= n; i++ )
if( n%i == 0 )
{
temp = xx(i);
while( n%i == 0 ){
sum += temp;
n/=i;
}
}
if(t==n)
return -1;
if(n!=1)
sum+=xx(n);
return sum;
}
int main()
{
int n,x;
while(scanf("%d",&n)&&n)
{
x=n+1;
while(xx(x)!=yy(x))
x++;
printf("%d\n",x);
}
return 0;
}