count=0 for i in range(1,1000): s=0 for a in range(1,i): if i%a ==0: s=s+a if s==i: print(i) count+=1 print("1~1000间的完数共有"+str(count)+"个")