水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI)、自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身。例如:1^3 + 5^3+ 3^3 = 153。
private static boolean isLotus(int n) {
if (n < 100 || n > 1000) {
// 不是三位数
return false;
}
// 百位
int n1 = n / 100;
// 十位
int n2 = (n % 100) / 10;
// 个位
int n3 = n % 10;
boolean flag = n == n1 * n1 * n1 + n2 * n2 * n2 + n3 * n3 * n3;
if (flag) {
System.out.println("水仙花数 [" + n + "] ===> 百位数为:" + n1 + ", 十位数为:" + n2 + ", 个位数为:" + n3);
}
return flag;
}



