@time: 2018/3/5 11:06 """ ''' 输出10000以内的水仙花数 水仙花数是指一个 n 位数(n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153) ''' def sxhua(): for x in range(100,10000): str_x = str(x) count = len(str_x) sum = 0 for i in str_x: sum = int(i)**count if sum == x: print(str_x + "是水仙花数") if __name__ == '__main__': sxhua()
python--水仙花数
猜你喜欢
转载自blog.csdn.net/maybe_frank/article/details/79492438
今日推荐
周排行