本文共 405 字,大约阅读时间需要 1 分钟。
'''求101-999中的水仙花数,水仙花数,个十百三数的立方相加等于本身'''from builtins import rangedef test1(): for i in range(101,1000): g=i%10 s=int(i/10)%10 b=int(i/100) if i==g**3+s**3+b**3: print(i)def test2(): for i in range(101,1000): st=str(i) g=int(st[2]) s=int(st[1]) b=int(st[0]) if i==g**3+s**3+b**3: print(i) test1()test2()
转载地址:http://fnym.baihongyu.com/