c求Smith数
#include <stdio.h>
int judgePriNum(int num){
//int k=(int)sqrt((double)num);
for(int i=2;i<num+1;i++){
if(num%i==0){
return 0;
}
if(i>num){
return 1;
}
}
}
int getPriSum(int num){
int sum=0;
while(num!=0){
sum += num%10;
num=num/10;
}
return sum;
}
int getComSum(int num){
int sum=0;
if(num>1){
for(int i=2;i<num;i++){
while(num%i==0){
//printf("%d\n",i);
sum+=getPriSum(i);
// printf("%d\n",sum);
num=num/i;
//printf("%d\n",num);
}
}
sum+=getPriSum(num);
}
return sum;
}
int main()
{
int num;
scanf("%d",&num);
int temp=num+1;
//printf("%d\n",temp);
while(judgePriNum(temp)==1){
temp++;
}
printf("%d ",getPriSum(temp));
printf("%d\n",temp);
}