求2到2000的完全数的和,用Python写出来
1个回答
2014-10-26
展开全部
python 2.7
x = [i for i in range(2, 2000) if int(i ** 0.5) == i ** 0.5]
print sum(x)
python 3.x
x = [i for i in range(2, 2000) if int(i ** 0.5) == i ** 0.5]
print (sum(x))
x = [i for i in range(2, 2000) if int(i ** 0.5) == i ** 0.5]
print sum(x)
python 3.x
x = [i for i in range(2, 2000) if int(i ** 0.5) == i ** 0.5]
print (sum(x))
追问
谢了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询