Question:The number 153 is a special number. It has the following attributes: 1. 13+53+33 = 153 2. For any positive integer which is multiple of 3, if we cube each digit and then get the sum, repeat this process, finally it will reach 153. For example: 12 13+23=9, 93=729, 73+23+93=1080, 13+03+83+03 = 513, 53+13+33=153
Please write a program to verify all the numbers under 1000 which are the multiple of 3.
/*Try to solve the problem with only the knowledge we have learnt so far. If cannot, you can also use other knowledge in C language.*/
#include<stdio.h>
int main()
{
int num;
for(num=1;num<1000;num++){
while(num%3==0){
L:int a=num/100;
int b=num/10%10;
int c=num%10;
num=a*a*a+b*b*b+c*c*c;
if(num!=153)
goto L;
if(num==153)
break;
}
printf("%d is a flower number\n",num);
}
}
希望有大佬能指点一下迷津,谢谢