第十三题

题目:

打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。

my_code:

def daffodil(num):
    index = False;
    bai = num // 100;
    shi = num // 10 % 10;
    ge =  num % 10;
    if bai**3+shi**3+ge**3 == num:
        index = True;
    return index
 
a=[];
for i in range(100,1000):
    if daffodil(i):
        a.append(i);
print(a);
print('the toall number is: ',len(a));
为更美好的明天而战!!!
原文地址:https://www.cnblogs.com/lovely-bones/p/11625510.html