Python输出三位数以内的水仙花数

1 num = 100
2 while num <= 999: 
3     a = num % 10                    #取个位数
4     b = num // 10 % 10              #取十位数
5     c = num // 100                  #取百位数
6     if num == a**3 + b**3 + c**3:
7         print (num)
8     num += 1                        #python不支持 num++ 之类的写法
posted @ 2020-01-15 15:59  zxkwdw  阅读(3399)  评论(0编辑  收藏  举报