水仙花数值:是一个三位数,其各位数字立方和等于该数字本身
例如:153=1*1*1+5*5*5+3*3*3
public class Example_one {
public static void main(String[] args) {
for(int i=100;i<1000;i++){
int ge=i%10;
int shi=i/10%10;
int bai=i/100;
if(ge*ge*ge+shi*shi*shi+bai*bai*bai==i){
System.out.println("水仙花数有:"+i);
}
}
}
}
水仙花数有:153
水仙花数有:370
水仙花数有:371
水仙花数有:407
Process finished with exit code 0