水仙花数-python3

"""
找出100~999之间的所有水仙花数
水仙花数是各位立方和等于这个数本身的数
如:153 = 1**3 + 5**3 + 3**3

Version: 1.0.0
Author: Catherine
Data: 2019-03-11
"""

for num in range(100, 1000):
    low = num % 10
    mid = num // 10 % 10
    high = num // 100
    if num == low ** 3 + mid ** 3 + high ** 3:
        print("{} 是水仙花数.".format(num))

猜你喜欢

转载自blog.csdn.net/u011280600/article/details/88391879