水仙花数有哪些?要100到1000之间所有的水仙花数

水仙花数100——1000有哪些?

定义:

水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI)、自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 n 位数(n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153)

package day0423;


public class suixianhuashu {

    /**
     * 水仙花数问题
     */
    public static void main(String[] args) {
        System.out.println("100-1000中的水仙花数有:");
        for (int i = 100; i < 1000; i++) {
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 10 / 10 % 10;

            //水仙花数判断要求
            if (i == (ge * ge * ge + shi * shi * shi + bai * bai * bai)) {
                System.out.println(i);
            }
        }


    }

}




猜你喜欢

转载自blog.csdn.net/libinxie/article/details/80072846