题目大意:本题讲的是判断一个数的各个数位之和是否等于将它分解成质数相乘形式时,各个数位之和;
#include<stdio.h>
#include<math.h>
long depart(long N)
{
long sum=0;
long i,a;
while(N>1)
{
for(i=2;i<=sqrt((double)(N));i++)
if(N%i==0)
{
for(a=i;a>0;a/=10)
sum+=a%10;
N/=i;
break;
}
if(i>sqrt((double)(N)) && sum!=0)
{
for(a=N;a>0;a/=10)
sum+=a%10;
N=1;
}
else
if(i>sqrt((double)(N))&&sum==0)
return 0;
}
return sum;
}
int main()
{
long n,temp,sum;
while(scanf("%ld",&n)&&n)
{
while(n++)
{
if(n>=110000000)
return 0;
sum=0;
temp=n;
while(temp)
{
sum+=temp%10;
temp/=10;
}
if(sum==depart(n))
{
printf("%ld\n",n);
break;
}
}
}
return 0;
}