'''
求101-999中的水仙花数,水仙花数,个十百三数的立方相加等于本身
'''
from builtins import range
def 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()
python学习12:水仙花
最新推荐文章于 2022-10-31 21:52:24 发布