标签:
51CTO上看到这个视频,自己试做一下:
尾数前移:N尾数是6,把6移到最前面后是N的4倍
def move_last_num():
a = 1
while True:
if 4 * (a * 10 + 6) == 6 * (10 ** len(str(a))) + a:
print(a)
return a
else:
a = a + 1
if __name__ == ‘__main__‘:
n = move_last_num()
N = n * 10 + 6
print(N)
水仙花数:一个n位数(n>=3),它的每个位上的数字的n次幂之和等于它本身
def roem():
for r in range(100,1000):
s = 0
n = len(str(r))
for i in range(n):
s = s + (int(str(r)[i]))**n
if s == r:
print(s)
if __name__ == ‘__main__‘:
roem()
标签:
原文地址:http://www.cnblogs.com/lostkite/p/5666999.html