用python 计算100~999的水仙花数的个数

# author : momo
#计算100~999的水仙花数的个数
sum = 0
for i in range(100,1000):
    a = 0
    temp = i
    while temp:
        a = a+(temp%10)**3
        temp //= 10
    if a == i:
        sum = sum +1
print(sum)

猜你喜欢

转载自blog.csdn.net/yuehongqqqq/article/details/81120606