程序内容:获取输入一个数字,获取输入的一个范围,将这个数字加减上下范围,判断这个范围内的数是否是完全数。
如果是完全数则输出perfect
存在问题:
1.当输入1001和1000时,28为非完全数。
2.当输入28和3时,28为完全数。
不清楚问题出在哪里。
希望指导。谢谢! :)
theNum=raw_input("enter number")
theNum=int(theNum)
theSpeace=raw_input("enter speace")
theSpeace=int(theSpeace)
theMax=theNum+theSpeace
theMin=theNum-theSpeace
while theMin
sumOfDivsors=0
divisor=1
while divisor
if theMin%divisor==0 :
sumOfDivsors=sumOfDivsors+divisor
divisor=divisor+1
if theMin==sumOfDivsors :
print theMin,"is perfect"
if theMin>sumOfDivsors :
print theMin,"is dificient"
if theMin
print theMin,"is abundant"
theMin=theMin+1