#找出水仙花数
def sxh(start, end):
    if end >= start and start >=100 and end<= 999:
        num=start #将num的值初始化
        L =[]
        while num<=end:
            x=num%10      #num取个位数
            y=num//10%10  #num取十位数
            z=num//100    #num取百位数
            if (num==pow(x,3)+pow(y,3)+pow(z,3)):
                L.append(num) #将num放在一个列表里
            num=num+1
        return L   #返回列表
print(sxh(100,999))

 

相关文章:

  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案