一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如6=1+2+3.
编程找出1000以内的所有完数。
haha=0
l=[]
a=int(raw_input("please input a number:\n"))
hehe=a
print 'hehe is %d ffff' % hehe
for k in range(2,a+1):
while(a != k):
if(a % k == 0):
l.append(k)
a=a/k
else:
break
l.append(a)
print l
for i in range(len(l)):
haha += l[i]
haha += 1
print 'haha is %d fdf' % haha
if(haha == hehe):
print 'good'
print 'hehe is %d' % hehe
阅读(2240) | 评论(0) | 转发(0) |