算法之水仙花数(Java语言)
概述 在 数论 中, 水仙花 数 ( Narcissistic number ),也被称为 超完全数字不变数 ( pluperfect digital invariant, PPDI )、 自恋 数 、 自幂数 、 阿姆斯壮 数 或 阿姆斯特朗数 ( Armstrong number ) ,用来描述一个 N 位非负整数,其各位数字的 N 次方和等于该数本身。 举例 例如153、370、371及407就是三位超完全数字不变数,其各个数之立方和等于该数: 153 = 1 3 + 5 3 + 3 3 。 370 = 3 3 + 7 3 + 0 3 。 371 = 3 3 + 7 3 + 1 3 。 407 = 4 3 + 0 3 + 7 3 。 Java算法 1 /** 2 * A Narcissistic number is a number that is the sum of its own digits each 3 * raised to the power of the number of digits. E.g., 0, 1, 2, 3, 4, 5, 6, 7, 8, 4 * 9, 153, 370, 371, 407, 1634, 8208, 9474. 5 */ 6 public class NarcissisticNumberExample { 7 /