水仙花数---基于python

# coding:utf-8
"""
水仙花数是指一个 n 位数(n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153)

题目:求100-999之间的水仙花数
"""
for i in range(100,1000):
    a=(int(str(i)[0]))**3
    b=(int(str(i)[1]))**3
    c=(int(str(i)[2]))**3
    if a+b+c==i:
        print i

原文地址:https://www.cnblogs.com/VseYoung/p/special_number_python.html