打印所有不超过n个(n <256)的,其平方具有对称性质的数。如11 * 11 = 121。
for i in range(1,256): l = i * i le = len(str(l)) lst = list(str(l)) k = le // 2 for j in range(k): if lst[j] == lst[le-1-j]: j += 1 continue break else: print(l)
for i in range(1,256): if str(i**2) == str(i**2)[::-1]: print(i)
原文:https://www.cnblogs.com/yuyafeng/p/11078823.html